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

Path test for tfvar files should accept paths outside of the module_root #98

Open sfozz opened 1 year ago

sfozz commented 1 year ago

Orb Version 3.0.0 and 3.1.0

Describe the bug In 2.1.0 you can pass in a absolute path to a var-file. which was honoured by https://github.com/CircleCI-Public/terraform-orb/blob/ac023bd48a8b48ac47da5f20fbd34e4b856dd6bf/src/commands/plan.yml#L98 however in the move to 3.0.0 this check was removed

To Reproduce

  1. create repo with a tfvar file that is outside of the module path, or directory that is set as current working directory
  2. set the command for terraform/plan similar to
    - terraform/plan:
    var_file: ${HOME}/common.tfvars

Expected behavior

the terraform/plan command will run because the script passes the test to confirm that the file exists. And not fail with the following error

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see any changes that are required for your infrastructure. All Terraform commands should now work.

If you ever set or change modules or backend configuration for Terraform, rerun this command to reinitialize your working directory. If you forget, other commands will detect it and remind you to do so if necessary. var file '${HOME}/common.tfvars' wasn't found

Exited with code exit status 1

NOTE

This is a duplicate of #56 as the 3.1.0 release did not fix the problem