Skip to content

Commit

Permalink
OCM-7551 | feat: add role console url in the output for policy attach
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolan018 committed Aug 20, 2024
1 parent 8ec1352 commit 7007659
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/aws/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
const (
awsManagedPolicyRegexPattern = `^arn:aws:iam::aws:policy/.*$`
awsManagedPolicyUrlPrefix = "https://docs.aws.amazon.com/aws-managed-policy/latest/reference/"
roleUrlPrefix = "https://console.aws.amazon.com/iam/home?#/roles/"
)

var (
Expand Down Expand Up @@ -216,7 +217,7 @@ func (c *awsClient) EnsureRole(reporter *reporter.Object, name string, policy st
if err != nil {
return roleArn, err
}
reporter.Infof("Attached trust policy to role '%s': %s", name, policy)
reporter.Infof("Attached trust policy to role '%s(%s)': %s", name, roleUrlPrefix+name, policy)

_, err = c.iamClient.TagRole(context.Background(), &iam.TagRoleInput{
RoleName: aws.String(name),
Expand Down Expand Up @@ -272,7 +273,7 @@ func (c *awsClient) createRole(reporter *reporter.Object, name string, policy st
}
return "", err
}
reporter.Infof("Attached trust policy to role '%s': %s", name, policy)
reporter.Infof("Attached trust policy to role '%s(%s)': %s", name, roleUrlPrefix+name, policy)
return aws.ToString(output.Role.Arn), nil
}

Expand Down Expand Up @@ -469,7 +470,7 @@ func (c *awsClient) AttachRolePolicy(reporter *reporter.Object, roleName string,
policyName := policyARNArr[len(policyARNArr)-1]
policyARN = fmt.Sprintf("%s(%s)", policyName, awsManagedPolicyUrlPrefix+policyName)
}
reporter.Infof("Attached policy '%s' to role '%s'\n", policyARN, roleName)
reporter.Infof("Attached policy '%s' to role '%s(%s)'\n", policyARN, roleName, roleUrlPrefix+roleName)
return nil
}

Expand Down

0 comments on commit 7007659

Please sign in to comment.