Skip to content

Destroy Ephemeral Environments #10988

Destroy Ephemeral Environments

Destroy Ephemeral Environments #10988

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@v4
- uses: hashicorp/setup-terraform@v3
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@v4
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)