hashicorp / tfc-workflows-github

HCP Terraform starter workflows and github actions to automate Terraform Cloud CI/CD pipelines.
Mozilla Public License 2.0
124 stars 20 forks source link

Vars file #10

Open churnd opened 1 year ago

churnd commented 1 year ago

Is there a way to specify a vars file to use? I see it is possible to specify vars individually via env vars but on larger projects, that's not exactly sustainable. I guess the equivalent of terraform apply -var-file="testing.tfvars"?

srlynch1 commented 11 months ago

This is achievable today the way you can approach this is to just output a tfvars file into the checked out repo prior to configuration upload

sany2k8 commented 2 months ago

@srlynch1 how to output an e.g. env/config.tfvars file into the checked-out repo before configuration upload? I need to do for both terraform plan and apply

churnd commented 2 months ago

You add a step to your pipeline to copy the config one directory up when the pipeline executes.

sany2k8 commented 2 months ago

@churnd Yes I am planning to do something like below in my workflow pipeline step, but I was expecting to pass some parameters in the upload action instead of doing this hacky stuff myself.

      - name: Generate environment wise auto.tfvars
        run: |
          infra_env=$INPUT_ENVIRONMENT
          cp env/${infra_env}.tfvars ${infra_env}.auto.tfvars
        env:
          INPUT_ENVIRONMENT: ${{ inputs.environment }}