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 #56

Closed sfozz closed 2 years ago

sfozz commented 2 years ago

Orb Version 3.0.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

KyleTryon commented 2 years ago

Hello!

A fix has been submitted in PR #76 and will be merged and released soon.

KyleTryon commented 2 years ago

Terraform Orb 3.1.0 is live: https://github.com/CircleCI-Public/terraform-orb/releases/tag/v3.1.0 Please try the latest version of the orb and let us know what you think!

Version 4.0.0 progress will begin soon with improved support for Terraform cloud and some new sensible defaults.

sfozz commented 1 year ago

Hi this hasn't fixed the issue... The check for the var file is still referencing the file path relative to the module path. If you have an absolute path then this fails