-
Notifications
You must be signed in to change notification settings - Fork 2
73 lines (62 loc) · 2.28 KB
/
gh_action_delete_infra.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Delete Flow Image in ECR Repo and then AWS Infrastructure
run-name: Remove Dataflow triggered by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
aws_region:
description: Desired region for AWS resources
required: true
default: 'eu-central-1'
type: string
ecr-repo-name:
required: true
description: name of the ecr repo to be deleted. Note- All immages in the repo will be deleted!
default: ''
type: string
jobs:
delete-aws-infrastructure:
name: Delete Flow Image and AWS Infrastructure
runs-on: ubuntu-latest
steps:
- name: Code Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install Pulumi Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
working-directory: infrastructure
- name: Set AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ github.event.inputs.aws_region }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Delete all images in specified ECR repo
run: |
aws ecr batch-delete-image \
--repository-name ${{ github.event.inputs.ecr-repo-name }} \
--image-ids "$(aws ecr list-images --repository-name ${{ github.event.inputs.ecr-repo-name }} \
--query 'imageIds[*]' --output json )" || true
# option: delete only deployed image
# aws ecr batch-delete-image \
# --repository-name ${{ github.event.inputs.ecr-repo-name }} \
# --image-ids imageTag=${{ github.event.inputs.flow-image-tag}}
- name: Delete Infrastructure with Pulumi
id: pulumi
uses: pulumi/actions@v3
with:
command: destroy
stack-name: ${{ github.actor }}/ecs-flow-infrastructure/dev
work-dir: infrastructure
env:
PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
- name: Summary
run: |
echo '### AWS infrastructure successfully deleted! :rocket:' >> $GITHUB_STEP_SUMMARY