Destroy Ephemeral Environments #10333
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: Destroy Ephemeral Environments | |
on: | |
schedule: | |
- cron: '30 * * * 1-6' | |
defaults: | |
run: | |
shell: bash | |
working-directory: ./terraform/environment | |
jobs: | |
destroy_workspace: | |
name: Destroy | |
runs-on: "ubuntu-latest" | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.2.4 | |
terraform_wrapper: false | |
- name: Install workspace manager | |
run: | | |
wget https://github.com/ministryofjustice/opg-terraform-workspace-manager/releases/download/v0.3.2/opg-terraform-workspace-manager_Linux_x86_64.tar.gz -O $HOME/terraform-workspace-manager.tar.gz | |
sudo tar -xvf $HOME/terraform-workspace-manager.tar.gz -C /usr/local/bin | |
sudo chmod +x /usr/local/bin/terraform-workspace-manager | |
- name: Configure AWS Credentials For Terraform | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
role-session-name: GitHubActionsTerraform | |
- name: Terraform init | |
run: | | |
terraform init | |
- name: Destroy Protected Workspaces | |
run: | | |
unset TF_WORKSPACE | |
./scripts/workspace_cleanup.sh $(terraform-workspace-manager -protected-workspaces=true -aws-account-id=288342028542 -aws-iam-role=integrations-ci) |