File tree Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Expand file tree Collapse file tree 2 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : Destroy Infrastructure
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ stage :
7
+ description : ' Environment to destroy (dev, qa, prod)'
8
+ required : true
9
+ default : ' dev'
10
+ type : choice
11
+ options :
12
+ - dev
13
+ - qa
14
+ - prod
15
+
16
+ env :
17
+ AWS_REGION : ap-south-1
18
+
19
+ jobs :
20
+ destroy :
21
+ runs-on : ubuntu-latest
22
+ steps :
23
+ - name : Set Stage
24
+ run : echo "STAGE=${{ github.event.inputs.stage }}" >> $GITHUB_ENV
25
+
26
+ - name : Checkout repository
27
+ uses : actions/checkout@v4
28
+
29
+ - name : Configure AWS credentials
30
+ uses : aws-actions/configure-aws-credentials@v4
31
+ with :
32
+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
33
+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
34
+ aws-region : ${{ vars.AWS_REGION }}
35
+
36
+ - name : Install Terraform
37
+ uses : hashicorp/setup-terraform@v2
38
+ with :
39
+ terraform_version : 1.6.6
40
+
41
+ - name : Destroy Terraform-managed infra
42
+ run : |
43
+ CONFIG_FILE="${STAGE}_config.tfvars"
44
+ cd terraform
45
+ terraform init
46
+ terraform destroy -var-file="$CONFIG_FILE" -auto-approve
Original file line number Diff line number Diff line change @@ -73,6 +73,6 @@ echo -e "\n"
73
73
74
74
echo " Terraform destroy will run after 5 minutes..."
75
75
echo " You can press ctrl+c and do it earlier as well"
76
- sleep 300
76
+ sleep 120
77
77
78
78
TF_LOG=DEBUG terraform destroy -var-file=" $CONFIG_FILE " -auto-approve
You can’t perform that action at this time.
0 commit comments