From 4f2b84eae13f8682589beba8e82cb1cf8af1d498 Mon Sep 17 00:00:00 2001 From: Patrick D'appollonio <930925+patrickdappollonio@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:27:17 -0500 Subject: [PATCH] Update with checks. --- cmd/aws/create.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index a9710401..fb4b0557 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -304,7 +304,8 @@ func createKubernetesAdminRole(ctx context.Context, clusterName string, iamClien // Check if the IAM policy exists cp, err := iamClient.GetPolicy(ctx, &iam.GetPolicyInput{PolicyArn: aws.String(fmt.Sprintf("arn:aws:iam::%s:policy/%s", *callerIdentity.Account, policyName))}) if err != nil { - if newError := (&awshttp.ResponseError{}); errors.As(err, newError) && newError.HTTPStatusCode() == http.StatusNotFound { + var newError awshttp.ResponseError + if errors.As(err, &newError) && newError.HTTPStatusCode() == http.StatusNotFound { // Policy does not exist, continue } else { return "", fmt.Errorf("failed to get policy %q: %w", policyName, err) @@ -352,7 +353,8 @@ func createKubernetesAdminRole(ctx context.Context, clusterName string, iamClien // Check if a role with this name already exists role, err := iamClient.GetRole(ctx, &iam.GetRoleInput{RoleName: aws.String(roleName)}) if err != nil { - if newError := (&awshttp.ResponseError{}); errors.As(err, newError) && newError.HTTPStatusCode() == http.StatusNotFound { + var newError awshttp.ResponseError + if errors.As(err, &newError) && newError.HTTPStatusCode() == http.StatusNotFound { // Role does not exist, continue } else { return "", fmt.Errorf("failed to get role %q: %w", roleName, err)