-
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
Variable interpolation syntax is confounding in non-trivial cases #744
Comments
@bitglue This is definitely something we are aware of and know needs re-thinking. For the initial TF release it was largely for variable references, with a few special cased functions. It has grown into a more general purpose "mini-language" but the implementation has not caught up. It currently uses some fairly bespoke regex and parser evaluators. Our goal is to replace it with a more formally defined language (backwards compatible mostly) and use a proper lexer / parser and AST. That should fix most of the bizarre parsing errors and provide a more formal definition of the language. Bare with us, as TF is a very young project still :) |
Note that we just opened #785 which makes the interpolation a lot more well defined, meaning you'll get nicer errors in a lot of cases. It is also now typed, so you'll get type errors in cases that don't make sense. So your one example is now like this:
|
I'm having some backwards compatibility issues. Here's an example of deploying CoreOS which worked with the v0.3.5 release, but does not work with this commit.
Not sure what a "multi-variable" is, but I guess it originates from the glob syntax? Shouldn't |
@bitglue That was just fixed this morning. |
Oh sorry...should have updated first. Now I'm getting a crash. I'll see if I can reduce the reproduction case and open a new issue. |
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. |
Nowhere in a the documentation can I find a formal or comprehensive description of the variable interpolation syntax. There are lots of trivial examples which just expand one variable:
Cool. What if I want to do something nontrivial? How about reading from a file. There's a function for that, and the documentation even gives an example:
${file("path.txt")}
. Neat. But now, I want to include that in my program, where it's already quoted. So, is that:or maybe...
or...
OK whatever, I'll just try them all until I find something that works. But hey, this is a module, and I want that to be relative to the module directory. There's an example:
Neat...but I also want to use the
file
function. So is that:or maybe...
Maybe something with that
join
function? No, that only works with the splat syntax.Oh jeez. I could think of a lot of ways it might be. I'm not sure if it's even possible.
The mental problem I'm having here is that a variable reference is not a string, and a function is not a variable, and
"
isn't a "begin interpretation of half-baked programming language" operator, but the Terraform syntax seems to conflate all of these things. It's very reminiscent of Bash, which has taken me years to understand, and which people mess up all the time. Please don't be like Bash, which has pages and pages in the manual on expansion because it's so hard to understand.The text was updated successfully, but these errors were encountered: