Skip to content

Conversation

SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Oct 3, 2025

This PR adds a new stateStoreInitFromConfig method that's similar to the existing backendInitFromConfig method on Meta.

The stateStoreInitFromConfig method added in this PR is used to get a backend.Backend instance that uses pluggable state storage internally. The returned PSS is configured using the configuration in the TF project, in contrast to the savedStateStore method that does the same but uses backend state files for configuring the state store. These methods are both analogous to backendInitFromConfig and savedBackend.

Additionally, this PR adds some test coverage for a related method, stateStoreConfig.

Target Release

N/A

Rollback Plan

  • If a change needs to be reverted, we will roll out an update to the code within 7 days.

Changes to Security Controls

Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

@SarahFrench SarahFrench added the no-changelog-needed Add this to your PR if the change does not require a changelog entry label Oct 3, 2025
Comment on lines +1673 to +1857
// NOTE: the backend version of this method, `backendInitFromConfig`, prompts users for input if any required fields
// are missing from the backend config. In `stateStoreInitFromConfig` we don't do this, and instead users will see an error.
func (m *Meta) stateStoreInitFromConfig(c *configs.StateStore, factory providers.Factory) (backend.Backend, cty.Value, cty.Value, tfdiags.Diagnostics) {
Copy link
Member Author

@SarahFrench SarahFrench Oct 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlighting this comment.

The backend equivalent of this method prompts users for input when required fields aren't set. I find this to be an odd feature; is this a first-class feature that gives users a preferable was to pass values into Terraform? If there are missing fields I'd expect an error to happen and users to update their config and/or ENVs.

I'm assuming it's a legacy-ish feature that we wouldn't choose to add now, so I've excluded it from this implementation. If feature request for this comes in future we can act on it.

@SarahFrench SarahFrench force-pushed the pss/add-state-stor-init-from-config-method branch from 525fe3b to eaf8717 Compare October 4, 2025 11:49
@SarahFrench SarahFrench marked this pull request as ready for review October 4, 2025 11:51
@SarahFrench SarahFrench requested a review from a team as a code owner October 4, 2025 11:51
@SarahFrench SarahFrench marked this pull request as draft October 4, 2025 12:43
@SarahFrench SarahFrench changed the title PSS: Add stateStoreInitFromConfig method to Meta PSS: Add stateStoreInitFromConfig method to Meta, update savedStateStore to include chunk size negotiation. Oct 4, 2025
@SarahFrench SarahFrench force-pushed the pss/add-state-stor-init-from-config-method branch from 7bc1477 to f5de2b3 Compare October 6, 2025 09:13
@SarahFrench SarahFrench changed the base branch from main to pss/add-chunk-negotiation-impl October 6, 2025 09:13
@SarahFrench SarahFrench changed the title PSS: Add stateStoreInitFromConfig method to Meta, update savedStateStore to include chunk size negotiation. PSS: Add stateStoreInitFromConfig method to Meta Oct 6, 2025
@SarahFrench SarahFrench force-pushed the pss/add-chunk-negotiation-impl branch from 28af9dd to 9237ded Compare October 6, 2025 09:18
@SarahFrench SarahFrench force-pushed the pss/add-state-stor-init-from-config-method branch from f5de2b3 to 9304b20 Compare October 6, 2025 09:30
@SarahFrench SarahFrench marked this pull request as ready for review October 6, 2025 09:55
Base automatically changed from pss/add-chunk-negotiation-impl to main October 6, 2025 15:04
@SarahFrench SarahFrench enabled auto-merge (squash) October 6, 2025 15:05

func configBodyForTest(t *testing.T, config string) hcl.Body {
t.Helper()
f, diags := hclsyntax.ParseConfig([]byte(config), "", hcl.Pos{Line: 1, Column: 1})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f, diags := hclsyntax.ParseConfig([]byte(config), "", hcl.Pos{Line: 1, Column: 1})
f, diags := hclsyntax.ParseConfig([]byte(config), "", hcl.InitialPos)

https://pkg.go.dev/github.com/hashicorp/hcl/[email protected]#pkg-variables

@SarahFrench SarahFrench merged commit d573104 into main Oct 6, 2025
7 checks passed
@SarahFrench SarahFrench deleted the pss/add-state-stor-init-from-config-method branch October 6, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants