-
Notifications
You must be signed in to change notification settings - Fork 37
45 lines (38 loc) · 1.24 KB
/
destroy.yml
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
name: Destroy
on:
workflow_dispatch:
inputs:
env:
description: select the environment
type: environment
required: true
env:
TF_VERSION: 1.5.7
environment: ${{ inputs.env }}
permissions:
id-token: write # This is required for requesting the JWT and AWS credentials using AssumeRoleWithWebIdentity
contents: read # This is required for actions/checkout
jobs:
destroy:
name: Destroy the app
runs-on: ubuntu-latest
environment:
name: ${{ inputs.env }}
steps:
- name: checkout the repo and building the Backend
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ vars.TERRAFORM_DEPLOY_ROLE_ARN }}
aws-region: ca-central-1
- name: terraform destroy
run: |
cd src/terraform
cat <<EOF > backend.hcl
bucket = "${{ vars.S3_BACKEND_NAME }}"
key = "${{ vars.LICENSEPLATE }}/${{ env.environment }}/startup-sample-app-aws-containers.tfstate"
dynamodb_table = "${{ vars.DYNAMO_DB_TABLE_NAME }}"
EOF
terraform init -backend-config=backend.hcl
terraform destroy -auto-approve