CircleCI-Public / terraform-orb

Deploy your infrastructure via a CircleCI pipeline using the Terraform orb. Integrate Infrastructure-as-Code (IaC) to help provision and manage any cloud, infrastructure, or service of your choice.
https://circleci.com/orbs/registry/orb/circleci/terraform
MIT License
10 stars 44 forks source link

Orb parameters don't work with CircleCI defined env vars #94

Open antonioned opened 1 year ago

antonioned commented 1 year ago

Orb Version 3.2.0

Describe the bug When using the orb, I can't find a way to use an env variable defined in the CircleCI contexts inside an orb command. In my example I have the terraform modules in different paths based on environment, something like env/qa and env/prod and I define the qa and prod part in an ENV env variable in the contexts, e.g. env/${ENV}.

However I configure this path I get the error

Path does not exist: ./env/${ENV}/

I tried using an absolute path as well, no luck.

To Reproduce

Use an environment variable in the path parameter in orb commands.

Expected behavior

I expect the orb to see and use the environment variables I set in CircleCI contexts or project settings.

bgridley commented 1 year ago

I found a workaround for this issue.

Change the shell in the job to something like this:

shell: /bin/sh -leo pipefail

Then add another command previous to the terraform/plan command like this:

  - run:
      name: Export envvars for terraform commands
      command: |
        echo "export ENV=${ENV}" >> $BASH_ENV