Skip to content

Scheduled/Manual terraform destroy #551

Scheduled/Manual terraform destroy

Scheduled/Manual terraform destroy #551

---
name: "Scheduled/Manual terraform destroy"
on:
workflow_dispatch:
schedule:
- cron: "0 17 * * 1-5" # Run the terraform destroy every workday at 18h UTC
jobs:
terraform-destroy:
runs-on: ubuntu-latest
env:
TF_ACTION_WORKING_DIR: .
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
DMS_TOKEN: ${{ secrets.DMS_TOKEN }}
TF_VAR_alertmanager_slack_route_api_url: ${{ secrets.ALERTMANAGER_SLACK_ROUTE_API_URL}}
steps:
- name: "Checkout the repository"
uses: actions/checkout@v4
- name: "Setup Terraform"
uses: hashicorp/setup-terraform@v3
- name: "Run terraform init"
id: init
run: "terraform init -no-color"
- name: "Delete some resources on the state file"
run: 'terraform state rm $(terraform-bin state list | grep "argocd_application\|argocd_project\|argocd_cluster\|argocd_repository\|kubernetes_\|helm_")'
continue-on-error: true # This is to avoid failed workflows and the consequent noise when the scheduled destroy runs on the days we have not created the test deployment
- name: "Run terraform destroy"
run: "terraform destroy -no-color -auto-approve -input=false"