Skip to content

tf destroy

tf destroy #4

name: "tf plan"
on:
pull_request:
env:
TF_CLOUD_ORGANIZATION: "zwell-test"
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
TF_WORKSPACE: "static-hosting"
CONFIG_DIRECTORY: "./terraform/"
jobs:
# Add jobs in to run checks
# linting
# unit test
terraform:
name: "tf plan devtest"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
# uploads/initiates a configuration in terraform
# akin to terraform init
- name: Upload Configuration
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@v1.0.0
id: plan-upload
with:
workspace: ${{ env.TF_WORKSPACE }}
directory: ${{ env.CONFIG_DIRECTORY }}
speculative: true
# runs changes in terrafrom/ against current state to create a tf.plan
# tarraform plan
- name: Create Plan Run
uses: hashicorp/tfc-workflows-github/actions/create-run@v1.0.0
id: plan-run
with:
workspace: ${{ env.TF_WORKSPACE }}
configuration_version: ${{ steps.plan-upload.outputs.configuration_version_id }}
plan_only: true
is_destroy: true
# Gets the plan and logs it in pipeline for debugging
- name: Get Plan Output
uses: hashicorp/tfc-workflows-github/actions/plan-output@v1.0.0
id: plan-output
with:
plan: ${{ fromJSON(steps.plan-run.outputs.payload).data.relationships.plan.data.id }}