Skip to content

Destroy Infrastructure #4

Destroy Infrastructure

Destroy Infrastructure #4

Workflow file for this run

name: Destroy Infrastructure
on:
workflow_dispatch:
inputs:
confirm_destroy:
description: Type destroy to confirm infrastructure teardown
required: true
permissions:
contents: read
id-token: write
jobs:
destroy-dev:
name: Destroy dev infrastructure
runs-on: ubuntu-latest
environment: dev
if: ${{ github.event.inputs.confirm_destroy == 'destroy' }}
env:
TF_VAR_project_id: ${{ vars.TF_VAR_PROJECT_ID }}
TF_VAR_region: ${{ vars.TF_VAR_REGION }}
TF_VAR_zone: ${{ vars.TF_VAR_ZONE }}
TF_VAR_environment: ${{ vars.TF_VAR_ENVIRONMENT }}
defaults:
run:
working-directory: terraform/gcp/envs/dev
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up OpenTofu
uses: opentofu/setup-opentofu@v2
with:
tofu_version: 1.11.6
- name: OpenTofu init
run: |
tofu init \
-backend-config="bucket=${{ vars.TF_BACKEND_BUCKET }}" \
-backend-config="prefix=${{ vars.TF_BACKEND_PREFIX }}"
- name: OpenTofu validate
run: tofu validate
- name: OpenTofu destroy
run: tofu destroy -auto-approve