Skip to content

Commit

Permalink
resolcing error
Browse files Browse the repository at this point in the history
  • Loading branch information
suvaanshkumar committed Feb 7, 2025
1 parent 6c91df4 commit 37dcf51
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pkg/registration/register/aws_irsa/approver.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,22 @@ func getPolicyArnByName(client *iam.Client, policyName string) (string, error) {
func createAccessEntriesForAWSIRSA(ctx context.Context,eksClient *eks.Client , principalArn string , hubClusterName string , managedClusterName string) error {

params := &eks.CreateAccessEntryInput{
ClusterName: aws.String(hubClusterName),
PrincipalArn: aws.String(principalArn),
Username: aws.String(managedClusterName),
KubernetesGroups: []string{"open-cluster-management:" + managedClusterName},
}
ClusterName: aws.String(hubClusterName),
PrincipalArn: aws.String(principalArn),
Username: aws.String(managedClusterName),
KubernetesGroups: []string{"open-cluster-management:" + managedClusterName},
}

createAccessEntryOutput, err := eksClient.CreateAccessEntry(ctx, params)
if err != nil {
if !(strings.Contains(err.Error(), "EntityAlreadyExists")) {
log.Printf("Failed to create Access entry for the managed cluster %v because of %v\n", managedClusterName, err)
return err
} else {
log.Printf("Ignore Access entry creation error as entity already exists")
}

if !(strings.Contains(err.Error(), "EntityAlreadyExists")) {
log.Printf("Failed to create Access entry for the managed cluster %v because of %v\n", managedClusterName, err)
return err
} else {
log.Printf("Ignore Access entry creation error as entity already exists")
}
}
fmt.Printf("Access entry created successfully: %s\n", *createAccessEntryOutput.AccessEntry.AccessEntryArn)

return nil
}

0 comments on commit 37dcf51

Please sign in to comment.