Skip to content

Commit a925290

Browse files
authored
Merge pull request #44573 from hashicorp/b-eusc-valid-arn
Correctly validate AWS European Sovereign Cloud Regions in ARNs
2 parents 722db46 + b44d36f commit a925290

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

.changelog/44573.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
provider: Correctly validate AWS European Sovereign Cloud Regions in ARNs
3+
```

internal/types/aws_region.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ import (
99

1010
// IsAWSRegion returns whether or not the specified string is a valid AWS Region.
1111
func IsAWSRegion(s string) bool { // nosemgrep:ci.aws-in-func-name
12-
return regexache.MustCompile(`^[a-z]{2}(-[a-z]+)+-\d{1,2}$`).MatchString(s)
12+
return regexache.MustCompile(`^[a-z]{2,4}(-[a-z]+)+-\d{1,2}$`).MatchString(s)
1313
}

internal/types/aws_region_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestIsAWSRegion(t *testing.T) { // nosemgrep:ci.aws-in-func-name
1818
{"", false},
1919
{"eu-isoe-west-1", true},
2020
{"mars", false},
21+
{"eusc-de-east-1", true},
2122
} {
2223
ok := IsAWSRegion(tc.id)
2324
if got, want := ok, tc.valid; got != want {

internal/verify/validate_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ func TestValidARN(t *testing.T) {
176176
"arn:aws-us-gov:s3:::bucket/object", // lintignore:AWSAT005 // GovCloud S3 ARN
177177
"arn:aws:cloudwatch::cw0000000000:alarm:my-alarm", // lintignore:AWSAT005 // CloudWatch Alarm
178178
"arn:aws:imagebuilder:eu-central-1:aws-marketplace:component/crowdstrike-falcon-install-linux-prod-nhzsem4gwwfja/1.2.2/1", // lintignore:AWSAT003,AWSAT005 // EC2 image builder marketplace subscription ARN
179+
"arn:aws-eusc:acm-pca:eusc-de-east-1:123456789012:certificate-authority/12345678-1234-1234-1234-123456789012", // lintignore:AWSAT003,AWSAT005 // ESC ACMPCA ARN
179180
}
180181
for _, v := range validNames {
181182
_, errors := ValidARN(v, "arn")

0 commit comments

Comments
 (0)