-
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
config: validate backend configuration can't contain interpolations #12067
Conversation
Do you think basic variables provided using a tfvars file could be interpolated at some point ? It would be extremely useful to pipeline code through different environments (ref below) without requiring an external logic for -backend-config. |
@nanoz Yes its possible. I find it important to start with a smaller surface area: you can always add things but you can't really take things away. For the variable issue, I'm concerned with restricting the TYPES of interpolations that are allowed in different areas of a Terraform config. My fear is that that leads to a future where a user is unclear what kind of interpolation they can use. You can claim (and I do) that we're already there with users unclear when they can/can't use interpolations. I view partial support as exacerbating that problem. I don't think there is an easy solution to it but without adding effectively unremovable features to the config, I'd rather ship with a more limited solution, consider this, and make it support more in the future. All that is to say: I want to head into a future where almost all of Terraform is parametrizable, I really do. But I want to do so with some more thought first. |
@mitchellh I saw some initial work towards adding a first-class "environment" concept to Terraform a few weeks ago, but didn't yet see enough of it to have a good mental model for how that construct will work. My hope was that it would include a means to either specify a separate remote configuration per environment within the config or to use the environment name as an interpolation within a single configuration, both of which would go some way to address the issue raised here. Currently at work we have a systematic way of constructing a remote state configuration given two pieces of information: a codebase name and an environment name. This allows us to centralize this convention in a single place, which for us is the wrapper script we use to run Terraform from a continuous integration/deployment tool. At the moment I find myself unsure how our current approach will adapt to the new architecture; if possible I'd like to avoid needing to hand-write the remote config for each environment+codebase pair into each repo, but it seems like for now that's going to be the recommended strategy. Is that right? I'm sure I can make something work with generating on the fly an additional config file that gives the remote config before running (I realize this is a bit of a big question to shove on the end of a closed issue. If there's documentation coming that will answer this question I'm happy to just wait and get my answers there... mainly just wanted to share the use-case.) |
@apparentlymart Scripting |
@mitchellh personally I agree that this is best kept for a later release, since this extra complexity should be approached with caution. In the long run it feels pragmatic to have three different possibilities for any configuration attribute:
The second case here is the awkward one, but when 0.9 ships we'll see with the I think the trick will be guiding users up the complexity curve so that they learn supporting concepts along the way. For example, a user should have learned what computed means before they are introduced to data sources, so that they can understand the ways in which a data source behaves differently than a resource. Based on earlier questions on this subject it's felt to me like the term "computed" isn't resonating with all users, so it might be worth spending some time researching alternative terminology here that might resonate better. With that said, none of the stuff in this comment is intended to disagree with this PR... just musing about possible future work. For now, dynamically generating a configuration file containing the backend config should work for anyone who was previously scripting calls to |
@apparentlymart can you please give me some hint on what do you mean by 'generate one-off configuration file that contains the desired settings'? I am experienced just with the local From my little experience, when I configure the backend as mentioned in #12200 and run |
The configuration I mean to generate is the terraform {
backend "foo" {
# ...
}
} From 0.9 the settings that were formerly passed to |
@apparentlymart They don't have to specifically, they just need to generate |
I think #12182 (Environments) could actually mitigate my concern. Needs testing :) |
I will be happy if
With that, I can avoid the |
Vote down for this PR. Whatever, I hope to get interpolations support back. I like it work as old And hope this type of PR can be reviewed not only one reviewer. It generates incompatible problem a lot. |
@SydOps We never supported interpolations in backend configurations (new in 0.9) and this was protecting people from using a feature we never supported. :) As I said above, we'd love to extend this support in the future, but we didn't take anything away to give "back": it never worked! In 0.9.0 we added more places you can use interpolations, we didn't roll any back at all, so I believe there is some confusion happening! |
Just noticed you mentioned |
Thanks, @mitchellh Since I can't make this work
Then I prefer to feed the environment variable to |
Right, I think we'll bring back the CLI based config too, but you can also use partial configurations, documented here: https://www.terraform.io/docs/backends/config.html (still requires a file but makes it more parameterizable) |
Thanks, @mitchellh Yes, that's what I did currently. In main.tf:
Then prepare a backend.conf file as
This backend.conf has to be generated every time in a wrap script before I run |
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. |
Validate that backend configuration doesn't contain interpolations.