-
Notifications
You must be signed in to change notification settings - Fork 1
41 lines (37 loc) · 1.44 KB
/
destroy_workspaces.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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)