Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/v1.12/ENHANCEMENTS-20250320-120304.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: ENHANCEMENTS
body: Optional skipping of the validation of the KMS key ID in the S3 backends.
time: 2025-03-20T12:03:04.152186-03:00
custom:
Issue: "36730"
12 changes: 11 additions & 1 deletion internal/backend/remote-state/s3/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type Backend struct {
useLockFile bool
workspaceKeyPrefix string
skipS3Checksum bool
skipKmsKeyIdValidation bool
}

// ConfigSchema returns a description of the expected configuration
Expand Down Expand Up @@ -215,6 +216,11 @@ func (b *Backend) ConfigSchema() *configschema.Block {
Optional: true,
Description: "Do not include checksum when uploading S3 Objects. Useful for some S3-Compatible APIs.",
},
"skip_kms_key_id_validation": {
Type: cty.Bool,
Optional: false,
Description: "Skip the KMS key ID validation.",
},
"sse_customer_key": {
Type: cty.String,
Optional: true,
Expand Down Expand Up @@ -660,7 +666,10 @@ func (b *Backend) PrepareConfig(obj cty.Value) (cty.Value, tfdiags.Diagnostics)
validateStringKMSKey,
},
}
kmsKeyIDValidators.ValidateAttr(val, attrPath, &diags)

if !b.skipKmsKeyIdValidation {
kmsKeyIDValidators.ValidateAttr(val, attrPath, &diags)
}
}

attrPath = cty.GetAttrPath("workspace_key_prefix")
Expand Down Expand Up @@ -837,6 +846,7 @@ func (b *Backend) Configure(obj cty.Value) tfdiags.Diagnostics {
b.ddbTable = stringAttr(obj, "dynamodb_table")
b.useLockFile = boolAttr(obj, "use_lockfile")
b.skipS3Checksum = boolAttr(obj, "skip_s3_checksum")
b.skipKmsKeyIdValidation = boolAttr(obj, "skip_kms_key_id_validation")

if _, ok := stringAttrOk(obj, "kms_key_id"); ok {
if customerKey := os.Getenv("AWS_SSE_CUSTOMER_KEY"); customerKey != "" {
Expand Down
8 changes: 8 additions & 0 deletions internal/backend/remote-state/s3/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2474,6 +2474,14 @@ func TestBackendConfigKmsKeyId(t *testing.T) {
),
},
},

"skip-validation": {
config: map[string]any{
"kms_key_id": "not-an-arn",
"skip_kms_key_id_validation" : True,
},
expectedKeyId: "not-an-arn",
},
}

for name, tc := range testCases {
Expand Down
Loading