-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (53 loc) · 1.87 KB
/
delete_stack.yml
File metadata and controls
58 lines (53 loc) · 1.87 KB
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
54
55
56
57
58
name: Delete Stack
run-name: "Delete ${{ inputs.stack-prefix }} stacks on ${{ inputs.region }} ${{ fromJson(vars.AWS_ACCOUNT_IDS_MAP)[inputs.account-id] }}"
env:
AWS_GITHUB_ROLE: 'cad-github-actions-role'
on:
workflow_dispatch:
inputs:
stack-prefix:
description: Prefix of stacks to remove
type: string
required: true
account-id:
description: AWS Account ID
type: string
required: true
region:
description: AWS Region
type: string
required: true
default: eu-west-1
jobs:
backend:
runs-on: ubuntu-22.04
timeout-minutes: 15
permissions:
id-token: write
contents: read
env:
AWS_STACK_PREFIX: ${{needs.aws-params.outputs.stack-prefix}}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{inputs.account-id }}:role/${{ env.AWS_GITHUB_ROLE }}
aws-region: ${{ inputs.region}}
- run: aws cloudformation delete-stack --stack-name ${{inputs.stack-prefix}}-backend
- run: aws cloudformation wait stack-delete-complete --stack-name ${{inputs.stack-prefix}}-backend
bootstrap:
runs-on: ubuntu-22.04
timeout-minutes: 15
# Only once the backend have been deleted can we remove the bootstrap stack
needs: [ backend ]
permissions:
id-token: write
contents: read
env:
AWS_STACK_PREFIX: ${{needs.aws-params.outputs.stack-prefix}}
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{inputs.account-id }}:role/${{ env.AWS_GITHUB_ROLE }}
aws-region: ${{ inputs.region}}
- run: aws cloudformation delete-stack --stack-name ${{inputs.stack-prefix}}-bootstrap
- run: aws cloudformation wait stack-delete-complete --stack-name ${{inputs.stack-prefix}}-bootstrap