Skip to content

Destroy Environment

Destroy Environment #6

Workflow file for this run

name: Destroy Environment
on:
workflow_dispatch:
inputs:
stage:
type: choice
description: Environment to destroy
options:
- dev
- qa
- prod
message:
required: true
env:
aws_account_id: ${{ vars.AWS_ACCOUNT_ID }}
aws_region: ${{ vars.AWS_REGION }}
aws_role: ${{ vars.AWS_ROLE }}
permissions:
id-token: write
contents: read
jobs:
destroy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ env.aws_region }}
role-to-assume: arn:aws:iam::${{ env.aws_account_id }}:role/${{ env.aws_role }}
role-session-name: GitHubActions
- name: Init
shell: bash
run: |
cd tf
terraform init
- name: Select Workspace
shell: bash
run: |
cd tf
terraform workspace select -or-create ${{ inputs.stage }}
terraform init
- name: Action
shell: bash
id: action
run: |
cd tf
terraform destroy -auto-approve -var function-stage=${{ inputs.stage }} -var lambda-zip-path=this_file_doesnt_exist.zip