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:

  • Add chunk negotiation code to savedStateStore and adds test coverage to that method.
  • Adds some test coverage for a related method, stateStoreConfig.

This PR is very similar to #37558, which implemented savedStateStore, a related method for getting a state store initialised using backend state, instead of config as we do here.

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 +1816
// 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

Choose a reason for hiding this comment

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

Highlighting this - I this prompting users for input when required fields aren't set is an odd feature and I'm not sure if it's used much. Is this to help users who forget to set values via config or their environment, or is this a first-class feature that's used to pass values into Terraform?

I'm assuming it's a legacy-ish feature that we wouldn't choose to add now, so figured we exclude it to start and we can wait for feature requests in future.

@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
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