-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Fix bug where -backend-config
could not override attributes that weren't at the top level in the backend schema
#36919
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
base: main
Are you sure you want to change the base?
Conversation
internal/command/init.go
Outdated
case isNested: | ||
// The flag item is overriding a nested attribute | ||
// e.g. assume_role.role_arn in the s3 backend | ||
// We assume a max nesting-depth of 1 as s3 is the only |
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.
Can we somehow bake this assumption in the code validation?
An input like "test_nesting_single.child.grand"
was allowed to pass with no error, and the child value ended up being set.
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.
I've addressed this by swapping to a solution that allows any level of nesting, and that change also addresses issues related to missing parent fields. I figured this was a better approach, as the alternative was to add an error asking users to report issues with overriding fields at a greater level of nesting, and why kick that issue down the road?
Thanks for the review @dsa0x! I think I'll pivot to a different approach so that this doesn't have that assumption about how many levels of nesting are present. But I'm learning more about navigating cty.Values in the process so it'll take a little time |
… paths are validated.
…es primitive type values/doesn't contain nested attributes itself
…riding a non-leaf attribute
Doing a pivot into investigating #36911 (comment) Edit: see my comment - I hit an issue with attributes that contain nested attributes that blocks using that project directly. I did like how using that project would reduce the code by a lot though. |
…uration being overridden
Fixes #36911
The bug reported in that issue is due to how the code that processes
-backend-config
flags assumes that any key=value pairs passed in are setting values for a top-level attribute in the backend's schema. The error shared in the fixed GH issue arises due to the code looking for a top-level field with the nameassume_role.role_arn
instead of looking forrole_arn
nested withinassume_role
.terraform/internal/command/init.go
Lines 1036 to 1044 in 474fe47
To enable testing of this update I needed access to a backend with a schema that matches the s3 backend's use of single nesting. Instead of adding a test that uses the s3 backend and needing to supply credentials, I've updated the inmem backend to optionally have an expanded backend for testing purposes. This is controlled by an environment variable specific to that backend. This could be a first step towards considering making the whole inmem backend not user facing and used 100% for tests.
Target Release
1.13.x
CHANGELOG entry