This is one of a suite of terraform related actions - find them at dflook/terraform-github-actions.
This action uses the terraform destroy
command to destroy all resources in a terraform workspace.
-
path
Path to the terraform configuration
- Type: string
- Required
-
workspace
Terraform workspace to destroy
- Type: string
- Optional
- Default:
default
-
variables
Variables to set for the terraform destroy. This should be valid terraform syntax - like a variable definition file.
with: variables: | image_id = "${{ secrets.AMI_ID }}" availability_zone_names = [ "us-east-1a", "us-west-1c", ]
Variables set here override any given in
var_file
s.- Type: string
- Optional
-
var
⚠️ Deprecated: Use thevariables
input instead.Comma separated list of terraform vars to set
- Type: string
- Optional
-
var_file
Comma separated list of tfvars files to use. Paths should be relative to the GitHub Actions workspace
- Type: string
- Optional
-
backend_config
Comma separated list of terraform backend config values.
- Type: string
- Optional
-
backend_config_file
Comma separated list of terraform backend config files to use. Paths should be relative to the GitHub Actions workspace
- Type: string
- Optional
-
parallelism
Limit the number of concurrent operations
- Type: number
- Optional
- Default: 10
-
TERRAFORM_CLOUD_TOKENS
API tokens for terraform cloud hosts, of the form
<host>=<token>
. Multiple tokens may be specified, one per line. These tokens may be used with theremote
backend and for fetching required modules from the registry.e.g for terraform cloud:
env: TERRAFORM_CLOUD_TOKENS: app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }}
With Terraform Enterprise or other registries:
env: TERRAFORM_CLOUD_TOKENS: | app.terraform.io=${{ secrets.TF_CLOUD_TOKEN }} terraform.example.com=${{ secrets.TF_REGISTRY_TOKEN }}
- Type: string
- Optional
-
TERRAFORM_SSH_KEY
A SSH private key that terraform will use to fetch git module sources.
This should be in PEM format.
For example:
env: TERRAFORM_SSH_KEY: ${{ secrets.TERRAFORM_SSH_KEY }}
- Type: string
- Optional
This example destroys the resources in a workspace named after the git branch when the associated PR is closed.
name: Cleanup
on:
pull_request:
types: [closed]
jobs:
destroy_workspace:
runs-on: ubuntu-latest
name: Destroy terraform workspace
steps:
- name: Checkout
uses: actions/checkout@v2
- name: terraform destroy
uses: dflook/terraform-destroy@v1
with:
path: my-terraform-config
workspace: ${{ github.head_ref }}