-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (43 loc) · 1.51 KB
/
terraform-destroy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Terraform Destroy
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
permissions: write-all
jobs:
destroy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: configure aws credentials
uses: aws-actions/[email protected]
with:
# role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
# role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: install terraform
uses: hashicorp/setup-terraform@v2
- name: checkout repository
uses: actions/checkout@v3
with:
submodules: 'true'
- name: configure kubectl
continue-on-error: true
run: |
aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }} --region ${{ secrets.AWS_REGION }}
- name: checkout code
uses: actions/checkout@v4
- name: delete resources created not managed by terraform
continue-on-error: true
run: |
kubectl delete -f kubernetes/ingress # deletes ALB created by aws-load-balancer-controller
kubectl delete nodeclaims --all # deletes nodes created by karpenter
sleep 60
- name: terraform init
run: terraform init
working-directory: terraform/environments/prod
- name: terraform destroy
run: terraform destroy -auto-approve -lock=false
working-directory: terraform/environments/prod