Skip to content

Commit

Permalink
OCM-8348 | test: Prepare additional principals role
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraj7 committed Jul 14, 2024
1 parent 4c98682 commit 906f917
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/aws/aws_client/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,22 @@ func (client *AWSClient) CreatePolicyForSharedVPC(policyName string) (string, er
}
return client.CreatePolicy(policyName, statement)
}

func (client *AWSClient) CreateRoleForAdditionalPrincipals(roleName string, installerRoleArn string) (types.Role, error) {
statement := map[string]interface{}{
"Sid": "Statement1",
"Effect": "Allow",
"Principal": map[string]interface{}{
"AWS": []string{installerRoleArn},
},
"Action": "sts:AssumeRole",
}

assumeRolePolicyDocument, err := completeRolePolicyDocument(statement)
if err != nil {
log.LogError("Failed to convert Role Policy Document into JSON: %s", err.Error())
return types.Role{}, err
}

return client.CreateRole(roleName, string(assumeRolePolicyDocument), "", make(map[string]string), "/")
}

0 comments on commit 906f917

Please sign in to comment.