-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
path.root is .
instead of full path since Terraform 0.12
#21400
Comments
This is the problem (
ebafa51#diff-f6b857536a7e1e29fac61431e919a8feL125 has introduced use of this function, I believe, and previously the path wasn't normalized. Since there is no good reason for normalizing the path, I'll put up a PR to go back to using |
Hi @AndiDog, Yes, this was intentional because encoding details about the machine where Terraform ran into a shared state is undesirable for many users, who want to be able to move their Terraform runs between contexts over time without upsetting things. Now people can use It sounds like in your case you are trying to generate relative paths against a different root... the root of your whole monorepo, I think? The CreatedFromTerraformRoot = pathrel("${path.cwd}/${path.root}"), "/path/to/git-repo") ...though I notice in your example you were using a regex pattern which I assume was intended to avoid the need to actually specify an absolute path by instead relying on the directory containing the git work tree to have a particular name. In that case, It does indeed seem like the missing part here is some functions to manipulate paths in a way that actually treats them as paths, rather than as generic strings... the With that said, since |
To clarify my use case again: I want to tag AWS resources in a way that others can find which Git repo + subdirectory the resource came from. Example:
I've added a PR for an |
Terraform 0.12 changed the behaviour of path.module to return a relative pathname rather than an absolute pathname. hashicorp/terraform#21400
* Update Gemfile.locks * Add support for Terraform v0.12 * Add version constraints to attributes module * Add version constraints to backend-ssh module This module can not support Terraform 0.12 until the Docker provider implements support. hashicorp/terraform-provider-docker#144 * Add version constraints to Plug Ins module * Add version constraints to variables module * Update Terraform to 0.11.14 on Ubuntu * Fix name of Ubuntu job Terragrunt is not used on Ubuntu * Update Terragrunt to 0.18.6 on MacOS * Update local provider to 1.2.2 * Update Terraform to 0.12.0 on MacOS * Add entry to CHANGELOG * Update local provider version constraint for 0.12 * Replace path.module with path.cwd Terraform 0.12 changed the behaviour of path.module to return a relative pathname rather than an absolute pathname. hashicorp/terraform#21400 * Declare terragrunt variables Declaring these variables will suppress undeclared variable warnings. * Remove escaped double quotes from string variable Terraform v0.12 evaluates the quotes as part of the string.
Hi again! Since your |
I find the justification for breaking backward compatibility presented in 2cf63d0 weak. IMO if a normalized-everywhere value was desired then it should have been added as an additional value and developer must bite the refactoring bullet and replace the internal uses of path.root with the new value. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Terraform Version
(installed via homebrew by editing source URL to
https://github.com/hashicorp/terraform/archive/v0.12.0.tar.gz
)Terraform Configuration Files
Expected Behavior
In v0.11.3, Terraform evaluates
${path.root}
to the full path, e.g./Users/asommer/dev/my-git-repo-dir
.In the above example, I would have expected to get a nice, descriptive EC2 instance tag which tells others from which Terraform files the resource was created, e.g.
CreatedFromTerraformRoot=my-git-repo-dir/staging/terraform
.Actual Behavior
With v0.12,
${path.root}
evaluates to.
Contrarily, I get this from the console mode:
Steps to Reproduce
Put the variable somewhere and look at the plan to see what value gets substituted.
The text was updated successfully, but these errors were encountered: