Remove Dataflow triggered by @mt7180 #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |