Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tfdrift workflow #63

Merged
merged 6 commits into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions .github/workflows/tfdrift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ on:
default: ""
type: string
description: 'Terraform var file directory. e.g. vars/dev.tfvars'
terraform_version:
type: string
default: 1.3.6
description: 'Required erraform version '
secrets:
AZURE_CREDENTIALS:
required: false
Expand All @@ -33,6 +37,12 @@ on:
aws_secret_access_key:
required: false
description: 'AWS Secret access key to install AWS CLI'
aws_session_token:
required: false
description: 'AWS Session Token to install AWS CLI'
build_role:
required: false
description: 'AWS OIDC role for aws authentication'
GITHUB:
required: true
description: 'PAT of the user to run the jobs.'
Expand All @@ -54,14 +64,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

# install AWS-cli
- name: Install AWS CLI
if: ${{ inputs.provider == 'aws' }}
uses: aws-actions/configure-aws-credentials@v2.2.0
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.aws_access_key_id }}
aws-secret-access-key: ${{ secrets.aws_secret_access_key }}
aws-session-token: ${{ secrets.aws_session_token }}
role-to-assume: ${{ secrets.build_role }}
aws-region: ${{ inputs.aws_region }}
role-duration-seconds: 900
role-skip-session-tagging: true

# Install azure-cli
- name: Install Azure CLI
Expand All @@ -70,26 +83,19 @@ jobs:
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Install the latest version of the Terraform CLI
- name: Setup Terraform
- name: Set up Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ${{ inputs.terraform_version }}

# Run some scripts
- name: Run shell commands
run: ls -la

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: "Terraform Init"
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_subcommand: "init"
tf_actions_version: 1.3.6
tf_actions_working_dir: ${{ inputs.working_directory }}
env:
GITHUB_TOKEN: '${{ secrets.GITHUB }}'
TF_CLI_ARGS: "-backend-config=token=${{ secrets.TF_API_TOKEN }}"
- name: terraform init
run: |
cd ${{ inputs.working_directory }}
terraform init

# Generates an execution plan for Terraform
# An exit code of 0 indicated no changes, 1 a terraform failure, 2 there are pending changes.
Expand Down