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
Can't use Bash parameter expansion #15933
Comments
Hi @MrOutis, Sequences that look like interpolation sequences can be escaped by doubling the quotes: username=$${USERNAME:-deploy} To reduce the impact of such conflicts, I usually recommend splitting the logic and the variables into two separate files. The template would then just be a wrapper around the main script, which is uploaded verbatim without any template processing. If having the result split into two separate files is not acceptable, an alternative is to have the main body of the script in a separate file within the Terraform config and then insert it as a template variable: data "template_file" "setup_server" {
template = "${file("../scripts/setup-server.sh.template")}"
vars {
project_name = "${var.project_name}"
aws_ecr_access_key = "${var.aws_ecr_access_key}"
aws_ecr_secret_key = "${var.aws_ecr_secret_key}"
logic = "${file("../scripts/setup-server-logic.sh")}"
}
} The file
Since the |
awesome, @apparentlymart! |
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
Terraform v0.9.8
Terraform Configuration Files
Crash Output
Expected Behavior
I expect that the variable
username
is set todepoly
, using mywiki.wooledge.org/BashGuide/Parameters#Parameter_ExpansionActual Behavior
Terraform thinks that every ${*} should be "substituted"
Steps to Reproduce
Render a template file that includes a variable with parameter expansion like the above
References
Didn't found
The text was updated successfully, but these errors were encountered: