Skip to content

Commit

Permalink
backend/s3: use aws alias name regex pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jar-b committed Oct 9, 2023
1 parent 60fb5d4 commit e46fe59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/backend/remote-state/s3/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
const (
multiRegionKeyIdPattern = `mrk-[a-f0-9]{32}`
uuidRegexPattern = `[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[ab89][a-f0-9]{3}-[a-f0-9]{12}`
aliasRegexPattern = `alias/(.*)`
aliasRegexPattern = `alias/[a-zA-Z0-9/_-]+`
)

func validateKMSKey(path cty.Path, s string) (diags tfdiags.Diagnostics) {
Expand Down Expand Up @@ -86,7 +86,7 @@ func keyIdFromARNResource(s string) string {
}

func aliasIdFromARNResource(s string) string {
aliasIdResourceRegex := regexp.MustCompile(`^` + aliasRegexPattern + `$`)
aliasIdResourceRegex := regexp.MustCompile(`^(` + aliasRegexPattern + `)$`)
matches := aliasIdResourceRegex.FindStringSubmatch(s)
if matches == nil || len(matches) != 2 {
return ""
Expand Down

0 comments on commit e46fe59

Please sign in to comment.