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

Ability to update a workspace variable. #30

Open mrinalirao opened 7 months ago

mrinalirao commented 7 months ago

Our team is using the tfc-workflows-github create-run to overwrite a workspace variable and to kick a run. We need a way/workflow to update the workspace variable via the github action workflow.

The terraform config files are in a different repository than from where the github actions are triggered. We are using a TFVAR* env var at the moment, but that only overwrites the variable for that run, but our requirement is that it is persisted in the workspace variables as well.

srlynch1 commented 7 months ago

Can you inject these vars into your config version post checkout but pre-upload something like the example below.

      - name: set-tfvars #auto tf vars  
        run: |
          echo 'organization="${{ vars.TF_CLOUD_ORGANIZATION }}"' >> pipeline-generated.auto.tfvars
          echo 'workspace-yaml-filepath="${{needs.tfe-ws-parent.outputs.admin_fileset}}"' >> pipeline-generated.auto.tfvars
          cat pipeline-generated.auto.tfvars