Skip to content

Commit 24a5c28

Browse files
tfdrift workflow (#63)
1 parent 999cfb0 commit 24a5c28

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

.github/workflows/tfdrift.yml

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ on:
2323
default: ""
2424
type: string
2525
description: 'Terraform var file directory. e.g. vars/dev.tfvars'
26+
terraform_version:
27+
type: string
28+
default: 1.3.6
29+
description: 'Required erraform version '
2630
secrets:
2731
AZURE_CREDENTIALS:
2832
required: false
@@ -33,6 +37,12 @@ on:
3337
aws_secret_access_key:
3438
required: false
3539
description: 'AWS Secret access key to install AWS CLI'
40+
aws_session_token:
41+
required: false
42+
description: 'AWS Session Token to install AWS CLI'
43+
build_role:
44+
required: false
45+
description: 'AWS OIDC role for aws authentication'
3646
GITHUB:
3747
required: true
3848
description: 'PAT of the user to run the jobs.'
@@ -54,14 +64,17 @@ jobs:
5464
- name: Checkout
5565
uses: actions/checkout@v3
5666

57-
# install AWS-cli
5867
- name: Install AWS CLI
5968
if: ${{ inputs.provider == 'aws' }}
60-
uses: aws-actions/configure-aws-credentials@v2.2.0
69+
uses: aws-actions/configure-aws-credentials@v2
6170
with:
6271
aws-access-key-id: ${{ secrets.aws_access_key_id }}
6372
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
73+
aws-session-token: ${{ secrets.aws_session_token }}
74+
role-to-assume: ${{ secrets.build_role }}
6475
aws-region: ${{ inputs.aws_region }}
76+
role-duration-seconds: 900
77+
role-skip-session-tagging: true
6578

6679
# Install azure-cli
6780
- name: Install Azure CLI
@@ -70,26 +83,19 @@ jobs:
7083
with:
7184
creds: ${{ secrets.AZURE_CREDENTIALS }}
7285

73-
# Install the latest version of the Terraform CLI
74-
- name: Setup Terraform
86+
- name: Set up Terraform
7587
uses: hashicorp/setup-terraform@v2
7688
with:
77-
terraform_wrapper: false
89+
terraform_version: ${{ inputs.terraform_version }}
7890

7991
# Run some scripts
8092
- name: Run shell commands
8193
run: ls -la
8294

83-
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
84-
- name: "Terraform Init"
85-
uses: hashicorp/terraform-github-actions@master
86-
with:
87-
tf_actions_subcommand: "init"
88-
tf_actions_version: 1.3.6
89-
tf_actions_working_dir: ${{ inputs.working_directory }}
90-
env:
91-
GITHUB_TOKEN: '${{ secrets.GITHUB }}'
92-
TF_CLI_ARGS: "-backend-config=token=${{ secrets.TF_API_TOKEN }}"
95+
- name: terraform init
96+
run: |
97+
cd ${{ inputs.working_directory }}
98+
terraform init
9399
94100
# Generates an execution plan for Terraform
95101
# An exit code of 0 indicated no changes, 1 a terraform failure, 2 there are pending changes.

0 commit comments

Comments
 (0)