Merge pull request #13699 from hashicorp/b-govcloud-kms-arns
provider/aws: Validate GovCloud KMS ARNs
This commit is contained in:
commit
788dbcb055
|
@ -353,7 +353,7 @@ func validateArn(v interface{}, k string) (ws []string, errors []error) {
|
|||
}
|
||||
|
||||
// http://docs.aws.amazon.com/lambda/latest/dg/API_AddPermission.html
|
||||
pattern := `^arn:[\w-]+:([a-zA-Z0-9\-])+:([a-z]{2}-[a-z]+-\d{1})?:(\d{12})?:(.*)$`
|
||||
pattern := `^arn:[\w-]+:([a-zA-Z0-9\-])+:([a-z]{2}-(gov-)?[a-z]+-\d{1})?:(\d{12})?:(.*)$`
|
||||
if !regexp.MustCompile(pattern).MatchString(value) {
|
||||
errors = append(errors, fmt.Errorf(
|
||||
"%q doesn't look like a valid ARN (%q): %q",
|
||||
|
|
|
@ -207,6 +207,7 @@ func TestValidateArn(t *testing.T) {
|
|||
"arn:aws:lambda:eu-west-1:319201112229:function:myCustomFunction", // Lambda function
|
||||
"arn:aws:lambda:eu-west-1:319201112229:function:myCustomFunction:Qualifier", // Lambda func qualifier
|
||||
"arn:aws-us-gov:s3:::corp_bucket/object.png", // GovCloud ARN
|
||||
"arn:aws-us-gov:kms:us-gov-west-1:123456789012:key/some-uuid-abc123", // GovCloud KMS ARN
|
||||
}
|
||||
for _, v := range validNames {
|
||||
_, errors := validateArn(v, "arn")
|
||||
|
|
Loading…
Reference in New Issue