Skip to content

Commit 5deeeef

Browse files
committed
added destroy.yml workflow
1 parent be48c5d commit 5deeeef

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

.github/workflows/destroy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

scripts/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ echo -e "\n"
7373

7474
echo "Terraform destroy will run after 5 minutes..."
7575
echo "You can press ctrl+c and do it earlier as well"
76-
sleep 300
76+
sleep 120
7777

7878
TF_LOG=DEBUG terraform destroy -var-file="$CONFIG_FILE" -auto-approve

0 commit comments

Comments
 (0)