diff --git a/internal/backend/remote-state/s3/backend.go b/internal/backend/remote-state/s3/backend.go index 7a67ea2a50..823385b9a8 100644 --- a/internal/backend/remote-state/s3/backend.go +++ b/internal/backend/remote-state/s3/backend.go @@ -942,7 +942,7 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics { ) b.acl = stringAttr(obj, "acl") - b.workspaceKeyPrefix = stringAttrDefault(obj, "workspace_key_prefix", "env:") + b.workspaceKeyPrefix = stringAttrDefault(obj, "workspace_key_prefix", defaultWorkspaceKeyPrefix) b.serverSideEncryption = boolAttr(obj, "encrypt") b.kmsKeyID = stringAttr(obj, "kms_key_id") b.ddbTable = stringAttr(obj, "dynamodb_table") diff --git a/internal/backend/remote-state/s3/backend_state.go b/internal/backend/remote-state/s3/backend_state.go index 217acf0f80..12ff6b88a9 100644 --- a/internal/backend/remote-state/s3/backend_state.go +++ b/internal/backend/remote-state/s3/backend_state.go @@ -22,6 +22,12 @@ import ( "github.com/hashicorp/terraform/internal/states/statemgr" ) +const ( + // defaultWorkspaceKeyPrefix is the default prefix for workspace storage. + // The colon is used to reduce the chance of name conflicts with existing objects. + defaultWorkspaceKeyPrefix = "env:" +) + func (b *Backend) Workspaces() ([]string, error) { const maxKeys = 1000