impl irsa controller

This commit is contained in:
kkb0318
2024-05-21 21:10:16 +09:00
parent eb2cc64b35
commit baf04dd46d
6 changed files with 290 additions and 67 deletions
+5 -2
View File
@@ -22,6 +22,9 @@ type RoleManager struct {
Namespaces []string
// Policies represents the list of policies to be attached to the role
Policies []string
// AccountId represents the AWS Account Id
AccountId string
}
func (r *RoleManager) PolicyArn(policy string) *string {
@@ -58,8 +61,8 @@ func (a *AwsIamClient) DeleteIRSARole(ctx context.Context, r RoleManager) error
}
// CreateIRSARole creates an IAM role with the specified trust policy and attaches specified policies to it
func (a *AwsIamClient) CreateIRSARole(ctx context.Context, accountId, issuerHostPath string, r RoleManager) error {
providerArn := fmt.Sprintf("arn:aws:iam::%s:oidc-provider/%s", accountId, issuerHostPath)
func (a *AwsIamClient) CreateIRSARole(ctx context.Context, issuerHostPath string, r RoleManager) error {
providerArn := fmt.Sprintf("arn:aws:iam::%s:oidc-provider/%s", r.AccountId, issuerHostPath)
statement := make([]map[string]interface{}, len(r.Namespaces))
for i, ns := range r.Namespaces {
statement[i] = map[string]interface{}{