Skip to content

Commit e236a60

Browse files
authored
Merge pull request #40640 from DerekTBrown/revert-40562-add-validation-for-iam-policy-document-sid
Revert 40562 add validation for iam policy document sid
2 parents 9de47bf + c9808a6 commit e236a60

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

.changelog/40562.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```release-note:enhancement
22
data-source/aws_iam_policy_document: Add plan-time validation that the `statement` `sid` is valid, including on alphanumeric characters
3-
```
3+
```

.changelog/40639.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
data-source/aws_iam_policy_document: Reverts plan-time validation for `statement` `sid`
3+
```

internal/service/iam/policy_document_data_source.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"strconv"
1212
"strings"
1313

14-
"github.com/YakDriver/regexache"
1514
"github.com/aws/aws-sdk-go-v2/aws"
1615
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1716
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -144,9 +143,10 @@ func dataSourcePolicyDocument() *schema.Resource {
144143
"principals": principalsSchema(),
145144
names.AttrResources: setOfStringSchema(),
146145
"sid": {
147-
Type: schema.TypeString,
148-
Optional: true,
149-
ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[a-zA-Z0-9]*$`), "must only include alphanumeric characters"),
146+
// Because policy documents are widely used outside IAM, we don't enforce
147+
// IAM validation rules requiring alphanumeric and no spaces.
148+
Type: schema.TypeString,
149+
Optional: true,
150150
},
151151
},
152152
},

internal/service/iam/policy_document_data_source_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,16 @@ func TestAccIAMPolicyDocumentDataSource_overrideList(t *testing.T) {
236236
})
237237
}
238238

239-
func TestAccIAMPolicyDocumentDataSource_validateSid(t *testing.T) {
239+
func TestAccIAMPolicyDocumentDataSource_invalidSidValid(t *testing.T) {
240240
ctx := acctest.Context(t)
241241
resource.ParallelTest(t, resource.TestCase{
242242
PreCheck: func() { acctest.PreCheck(ctx, t) },
243243
ErrorCheck: acctest.ErrorCheck(t, names.IAMServiceID),
244244
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
245245
Steps: []resource.TestStep{
246246
{
247-
Config: testAccPolicyDocumentDataSourceConfig_invalidSid,
248-
ExpectError: regexache.MustCompile(`must only include alphanumeric characters`),
247+
Config: testAccPolicyDocumentDataSourceConfig_invalidSid,
248+
PlanOnly: true,
249249
},
250250
},
251251
})
@@ -1040,7 +1040,7 @@ data "aws_iam_policy_document" "test_source_conflicting" {
10401040
var testAccPolicyDocumentDataSourceConfig_invalidSid = `
10411041
data "aws_iam_policy_document" "test" {
10421042
statement {
1043-
sid = "Invalid_SID"
1043+
sid = "Invalid SID"
10441044
actions = [
10451045
"s3:ListAllMyBuckets",
10461046
"s3:GetBucketLocation",

0 commit comments

Comments
 (0)