Delete Dev Environment #18
Workflow file for this run
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 Dev Environment" | |
on: | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
env: | |
AWS_REGION: ca-central-1 | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }} | |
permissions: | |
id-token: write # This is required for requesting the OIDC JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
terraform-destroy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Configure AWS credentials using OIDC | |
uses: aws-actions/configure-aws-credentials@8c3f20df09ac63af7b3ae3d7c91f105f857d8497 # v4.0.0 | |
with: | |
role-to-assume: arn:aws:iam::800095993820:role/notification-terraform-apply | |
role-session-name: TerragruntDestroy | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Checkout | |
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
- name: Install 1Pass CLI | |
run: | | |
curl -o 1pass.deb https://downloads.1password.com/linux/debian/amd64/stable/1password-cli-amd64-latest.deb | |
sudo dpkg -i 1pass.deb | |
- name: One Password Fetch | |
run: | | |
op read op://4eyyuwddp6w4vxlabrr2i2duxm/"TFVars - Dev"/notesPlain > /var/tmp/dev.tfvars | |
- name: Setup Terraform tools | |
uses: cds-snc/terraform-tools-setup@v1 | |
env: # In case you want to override default versions | |
CONFTEST_VERSION: 0.30.0 | |
TERRAFORM_VERSION: 1.6.2 | |
TERRAGRUNT_VERSION: 0.44.4 | |
TF_SUMMARIZE_VERSION: 0.2.3 | |
- name: Inject token authentication | |
run: | | |
git config --global url."https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/".insteadOf "https://github.com/" | |
- name: Destroy aws/system_status_static_site | |
run: | | |
cd env/dev/system_status_static_site | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/system_status | |
run: | | |
cd env/dev/system_status | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/lambda-google-cidr | |
run: | | |
cd env/dev/lambda-google-cidr | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
# This must be run before quicksight destroy | |
- name: Destroy quicksight VPC Connection | |
continue-on-error: true | |
run: | | |
aws quicksight delete-vpc-connection --aws-account-id 800095993820 --vpc-connection-id $(aws quicksight list-vpc-connections --aws-account-id 800095993820 --query 'VPCConnectionSummaries[].VPCConnectionId' --output text) | |
# - name: Destroy aws/quicksight | |
# run: | | |
# cd env/dev/quicksight | |
# terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/database-tools | |
run: | | |
cd env/dev/database-tools | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/heartbeat | |
run: | | |
cd env/dev/heartbeat | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/lambda-api | |
run: | | |
cd env/dev/lambda-api | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/rds | |
run: | | |
cd env/dev/rds | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/elasticache | |
run: | | |
cd env/dev/elasticache | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/eks | |
# This will fail if spot instances exist. We will delete them manually in the next step. We can't delete them first because Karpenter will recreate them. | |
continue-on-error: true | |
run: | | |
cd env/dev/eks | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Clean Up Lingering EKS | |
# This will fail if there are no instances to delete. I'm too lazy to check if we need to delete first. A future TODO. | |
continue-on-error: true | |
run: | | |
./scripts/eksDestroyCleanup.sh | |
- name: Destroy aws/eks | |
run: | | |
cd env/dev/eks | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/cloudfront | |
run: | | |
cd env/dev/cloudfront | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/ses_validation_dns_entries | |
run: | | |
cd env/dev/ses_validation_dns_entries | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/dns | |
run: | | |
cd env/dev/dns | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/pinpoint_to_sqs_sms_callbacks | |
run: | | |
cd env/dev/pinpoint_to_sqs_sms_callbacks | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/sns_to_sqs_sms_callbacks | |
run: | | |
cd env/dev/sns_to_sqs_sms_callbacks | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/ses_to_sqs_email_callbacks | |
run: | | |
cd env/dev/ses_to_sqs_email_callbacks | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/ses_receiving_emails | |
run: | | |
cd env/dev/ses_receiving_emails | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
- name: Destroy aws/ecr | |
run: | | |
cd env/dev/ecr | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars | |
# We need to clean up the internal load balancers created by EKS. | |
- name: Cleanup Internal Load Balancers | |
run: | | |
./scripts/cleanupELB.sh | |
- name: Destroy aws/common | |
run: | | |
cd env/dev/common | |
terragrunt destroy --terragrunt-non-interactive -auto-approve -var-file /var/tmp/dev.tfvars |