- Notifications
You must be signed in to change notification settings - Fork10.1k
Updatebackendbase to use empty strings from configuration, instead of looking for fallback or ENV values#37877
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 ourterms of service andprivacy 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
…stead of ignoring them and looking for ENVs or fallback values. Add test coverage.
Previously the test assumed if the default wasn't used then no ENV would be used either.
SarahFrench commentedNov 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
FYI @hashicorp/terraform-azure : The reported error is not specific to the Azure backend, but I explored adding a test that shows empty strings are used specifically in the |
…ngs are used as-is
| }) | ||
| } | ||
| funcTestBase_emptyStringsUsed(t*testing.T) { |
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 realised this overlaps somewhat withTestSDKLikeApplyEnvDefaults, but maybe it's useful to have this as a more explicit regression test?
Uh oh!
There was an error while loading.Please reload this page.
Fixes#37846
In#37225 (a rebased version of#34990) the azure backend was updated to use the new
backendbasepackage instead of the legacy SDK. This was the last backend migrated over.Now, the structs representing remote-state backend implementations embed
backendbase.Base(example inazure). If the remote-state backend doesn't implement methods likePrepareConfigthen the implementation of that method inbackendbase.Baseis used instead.In the case of the original issue reported about the Azure backend, the
azurebackend doesn't implementPrepareConfigitself and instead uses the implementation inbackendbase.Base. In that method there is logic that didn't accurately mimic how the legacy SDK handled attributes that were explicitly set to an empty string in the configuration:Instead of using the empty string value like the legacy SDK, the new
backendbasepackage looks for any fallback values defined for that attribute in backend'sSDKLikeDefaultsvalues; default values defined in the schema or names of environment variables to use. The PrepareConfig method returns data about how the backend should be configured, a combo of config, schema defaults, and ENV values, and then Terraform Core then uses that value to configure the backend.This PR
backendbasepackage to detect non-null, string attributes that are set to""and uses that value, reverting behaviour back to match the legacy SDK.PrepareConfigstill includes the empty string, and that'll be used to configure the backend.Target Release
1.15.x
Rollback Plan
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
CHANGELOG entry