From 6d83d839eda4e3d87efbafde17fefebd4d433c53 Mon Sep 17 00:00:00 2001 From: Patrick D'appollonio <930925+patrickdappollonio@users.noreply.github.com> Date: Thu, 16 Jan 2025 14:25:03 -0500 Subject: [PATCH] Update with checks. --- cmd/aws/create.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cmd/aws/create.go b/cmd/aws/create.go index 3625fb07..a9710401 100644 --- a/cmd/aws/create.go +++ b/cmd/aws/create.go @@ -304,8 +304,7 @@ 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 { - var newError *awshttp.ResponseError - if errors.As(err, newError) && newError.HTTPStatusCode() == http.StatusNotFound { + if newError := (&awshttp.ResponseError{}); 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) @@ -353,8 +352,7 @@ 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 { - var newError *awshttp.ResponseError - if errors.As(err, newError) && newError.HTTPStatusCode() == http.StatusNotFound { + if newError := (&awshttp.ResponseError{}); 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)