Skip to content

Commit 75ed895

Browse files
committed
feat: add plan_only input to support only terraform-plan
1 parent cc90004 commit 75ed895

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

.github/workflows/terraform_workflow.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ on:
2828
required: false
2929
type: boolean
3030
default: false
31-
description: 'Set true to to destroy terraform infrastructure.'
31+
description: 'Set true to destroy terraform infrastructure.'
3232
approvers:
3333
required: false
3434
type: string
3535
description: 'Approvals list to approve apply or destroy'
3636
terraform_version:
3737
type: string
3838
default: 1.3.6
39-
description: 'Required erraform version '
39+
description: 'Required Terraform version'
4040
timeout:
4141
required: false
4242
type: number
@@ -76,6 +76,11 @@ on:
7676
required: false
7777
type: string
7878
default: ""
79+
plan_only:
80+
description: "Set this to `true` to run `terraform plan` only"
81+
required: false
82+
type: boolean
83+
default: false
7984
secrets:
8085
AZURE_CREDENTIALS:
8186
required: false
@@ -239,6 +244,7 @@ jobs:
239244
echo "${delimiter}" >> $GITHUB_OUTPUT
240245
241246
- name: "Accept plan or deny"
247+
if: ${{ inputs.plan_only != true }}
242248
uses: trstringer/manual-approval@v1
243249
timeout-minutes: ${{ inputs.timeout }}
244250
with:
@@ -248,7 +254,7 @@ jobs:
248254
issue-title: "Terraform Plan for Infrastructure Update"
249255

250256
- name: terraform apply
251-
if: ${{ inputs.destroy != true }}
257+
if: ${{ inputs.destroy != true && inputs.plan_only != true }}
252258
run: |
253259
if [ -n "${{ inputs.var_file }}" ]; then
254260
cd ${{ inputs.working_directory }}

docs/terraform-checks.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ jobs:
1717
tf-static-checks:
1818
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
1919
with:
20-
working_directory: './_example/complete/'
21-
# terraform_version: 0.12.31 // Specify the Terraform version to use. Uncomment and provide your desired version, or leave it as is to use the latest version.
22-
aws_credentials: false // Provide your AWS Credentails ID here if 'aws_credentials' is set to 'true'.
20+
working_directory: # Specify terraform code directory in repo, eg. './_example/complete/'
21+
terraform_version: # Specify terraform version e.g 1.3.6
22+
provider: # aws
23+
aws_region: # specify region eg. us-east-2
2324
secrets:
2425
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
2526
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

docs/terraform_workflow.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ jobs:
1919
uses: clouddrove/github-shared-workflows/.github/workflows/terraform_workflow.yml@master
2020
with:
2121
provider: # aws
22-
working_directory: # Specify terraform code directory in repo
23-
var_file: # name of tfvar file e.g "variable.tfvar"
22+
working_directory: # Specify terraform code directory in repo, eg. './_example/complete/'
23+
var_file: # name of tfvar file, eg. "variable.tfvar"
2424
aws_region: # specify region eg. us-east-2
2525
approvers: # Assignee name for approve apply or destroy step
2626
minimum-approvals: # Minimum number of approvals required to progress the workflow, deafault value is 1
2727
terraform_version: # Specify terraform version e.g 1.3.6
28+
plan_only: # If the value is set to true, the workflow will only show terraform plan
2829
destroy: # If the value is set to true, the workflow proceeds to the destroy step. However, the default value is false
2930
secrets:
3031
AWS_ACCESS_KEY_ID: # Specify AWS Access key ID

0 commit comments

Comments
 (0)