1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

Remove unused capture groups from KMS ARN parsing

This commit is contained in:
Adrian Utrilla
2017-08-15 11:49:14 -07:00
parent 6c8809285f
commit ada1461d2f

View File

@@ -140,13 +140,12 @@ func (key MasterKey) createStsSession(config aws.Config, sess *session.Session)
}
func (key MasterKey) createSession() (*session.Session, error) {
// possible partitions in $1: aws, aws-cn, aws-us-gov
re := regexp.MustCompile(`^arn:(aws[\w-]*):kms:(.+):([0-9]+):key/(.+)$`)
re := regexp.MustCompile(`^arn:aws[\w-]*:kms:(.+):[0-9]+:key/.+$`)
matches := re.FindStringSubmatch(key.Arn)
if matches == nil {
return nil, fmt.Errorf("No valid ARN found in %q", key.Arn)
}
config := aws.Config{Region: aws.String(matches[2])}
config := aws.Config{Region: aws.String(matches[1])}
opts := session.Options{
Config: config,
AssumeRoleTokenProvider: stscreds.StdinTokenProvider,