Skip to content

Conversation

@SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Oct 20, 2025

This PR copies a bunch of code from the existing inmem backend and uses it to create an inmem version of a pluggable state store in the builtin terraform provider.

This will only be accessible if a user has TF_ACC set in their environment, which is a standard ENV for enabling test-specific behaviour or actions. This won't fully block a user from accessing the state store, but it provides more friction than the current inmem backend, which is just not documented.

I'm sharing this work for feedback before adding it to terraform-provider-simple6, for E2E testing

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 20, 2025
Comment on lines +23 to +30
// InMemStoreSingle allows 'storing' state in memory for the purpose of testing.
//
// "Single" reflects the fact that this implementation does not use any global scope vars
// in its implementation, unlike the current inmem backend. HOWEVER, you can test whether locking
// blocks multiple clients trying to access the same state at once by creating multiple instances
// of backend.Backend that wrap the same provider.Interface instance.
type InMemStoreSingle struct {
states stateMap
locks lockMap
Copy link
Member Author

Choose a reason for hiding this comment

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

For context, the inmem backend uses these global vars:

// we keep the states and locks in package-level variables, so that they can be
// accessed from multiple instances of the backend. This better emulates
// backend instances accessing a single remote data store.
var (
states stateMap
locks lockMap
)

Like the code comment says, multiple backends can attempt to access the same state by using the same providers.Interface instance to create them.

@SarahFrench SarahFrench changed the title PSS : Add inmem state storage implementation to the builtin terraform provider PSS : Add inmem state storage implementation to the builtin terraform provider, update grpcwrap package, use PSS implementation in E2E test Oct 24, 2025
@SarahFrench SarahFrench force-pushed the pss/add-builtin-inmem-state-storage-implementation branch from a4887d9 to ef6dc39 Compare October 24, 2025 11:04
Comment on lines 110 to +111
run: |
TF_ACC=1 go test -v ./internal/command/e2etest
TF_TEST_EXPERIMENT=1 TF_ACC=1 go test -v ./internal/command/e2etest
Copy link
Member Author

Choose a reason for hiding this comment

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

Something to bear in mind is that E2E tests also run in the context of the build workflow. I think it'd best to avoid enabling experiments to leak to that workflow, and instead have experimental tests skipped when running in that context.

@SarahFrench SarahFrench force-pushed the pss/add-builtin-inmem-state-storage-implementation branch from 15b80f9 to 0f01ff6 Compare October 24, 2025 11:36
@SarahFrench SarahFrench force-pushed the pss/add-builtin-inmem-state-storage-implementation branch from 0f01ff6 to 2fadb1e Compare October 24, 2025 11:38
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.

1 participant