Skip to content

Commit

Permalink
feat: Added replace tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanishdrove committed Jan 15, 2025
1 parent af90f87 commit ca1f647
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions .github/workflows/terraform_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,44 @@ run-name: 'Terraform workflow'
on:
workflow_call:
inputs:
replace_tokens:
required: true
type: boolean
default: true
description: 'Set true to replace tokens in the terraform files.'
environmentName:
required: false
type: string
default: "dev"
terraform_version:
required: false
type: string
default: "1.8.0"
region:
required: false
type: string
default: "canadaeast"
working_directory:
required: true
type: string
default: "terraform/common"
description: 'Root directory of the terraform where all resources exist.'
resourceName:
required: false
type: string
default: "moduletestref"
backend_rg_name:
required: false
type: string
default: "terraform-state-rg"
backend_sa_name:
required: false
type: string
default: "tfstatestorageaccountest"
backend_container_name:
required: false
type: string
default: "terraform-state"
provider:
required: true
type: string
Expand Down Expand Up @@ -117,8 +151,28 @@ jobs:
tfplanExitCode: ${{ steps.tf-plan.outputs.exitcode }}

steps:
# - name: Checkout
# uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4

- name: Update environment variables
if: ${{ inputs.replace_tokens == true }}
uses: cschleiden/replace-tokens@v1
with:
tokenPrefix: '#{'
tokenSuffix: '}#'
files: '["${{ inputs.working_directory }}/main.tf", "${{ inputs.working_directory }}/backend.tf"]'
env:
RESOURCE_NAME: ${{ inputs.resourceName }}
SUBSCRIPTION_ID: "${{ secrets.AZURE_SUBSCRIPTION_ID }}"
ENV_NAME: ${{ inputs.environmentName }}
REPLACE_REGION: ${{ inputs.region }}
CLIENT_ID: "${{ secrets.AZURE_CLIENT_ID }}"
CLIENT_SECRET: "${{ secrets.AZURE_CLIENT_SECRET }}"
TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
BACKEND_RG_NAME: ${{ inputs.backend_rg_name }}
BACKEND_SA_NAME: ${{ inputs.backend_sa_name }}
BACKEND_CONTAINER_NAME: ${{ inputs.backend_container_name }}


- name: Set environment variables
run: |
Expand Down

0 comments on commit ca1f647

Please sign in to comment.