-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Clarify use of backend-config file #35389
base: main
Are you sure you want to change the base?
Conversation
It is not a "full override" as one might expect. It works only within the context of an existing partial configuration.
Thanks for this submission! |
@crw Do you think this contribution is worth keeping? I'm happy to resolve conflicts, or we can close if this isnt helpful. |
Hi @asmacdo, let me check with the docs team. I think this may have been misplaced due to some changes in how we were working with documentation changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some suggestions to improve the clarity and style.
- Using a backend configuration file or CLI key-value pairs overrides the contents, | ||
but not the type of `backend`. (e.g. Use a Partial Configuration in the primary config.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Using a backend configuration file or CLI key-value pairs overrides the contents, | |
but not the type of `backend`. (e.g. Use a Partial Configuration in the primary config.) | |
You can use the `-backend-config` flag on the CLI to provide a backend configuration. You can either specify a file containing a partial configuration or specify a set of key-value pairs. Terraform applies the configurations to the arguments in the `backend` block, but it does not change the type. In the following example, Terraform stores state in the default backend using the arguments supplied in the `-backend-config` flag: |
I think this is the point you are making?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but it does miss one of the key things I wanted to document. I was surprised when trying to use this that I needed a partial configuration in the primary config, I guessed I could have just provided the backend from scratch in the override.
Changelog WarningCurrently this PR would target a v1.12 release. Please add a changelog entry for in the .changes/v1.12 folder, or discuss which release you'd like to target with your reviewer. If you believe this change does not need a changelog entry, please add the 'no-changelog-needed' label. |
-backend-config
It is not a "full override" as one might expect. It works only within the context of an existing partial configuration.I'm not confident that my docs changes are exactly correct-- but hopefully this will make things a little clearer. I realize this is within the "Partial Configuration" section, but I still found the behavior a little surprising.
(Why do I need to do this? I am using multiple tf environments, which must store their state separately.)
I (as suggested by a confused ChatGPT) attempted:
myfile.tf
IMO this seems like a pretty reasonable expectation. I did receive a warning that it wasn't overriding any specific config, but I thought that seemed ok. What I absolutely did not expect was that tf would proceed and store my tfstate locally.
The
helptext
was a little more helpful.What ended up working for me:
backend.tf
myfile.tf