Skip to content

Commit 5844c77

Browse files
cheina97adamjensenbot
authored andcommitted
Liqoctl AWS install: added user-name warning
1 parent 3000373 commit 5844c77

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

pkg/liqoctl/install/eks/iam.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ func (o *Options) ensureUser(iamSvc *iam.IAM) error {
7373
UserName: aws.String(o.iamUser.userName),
7474
}
7575

76-
_, err := iamSvc.CreateUser(createUserRequest)
77-
if err != nil {
76+
if _, err := iamSvc.CreateUser(createUserRequest); err != nil {
77+
if aerr, ok := err.(awserr.Error); ok { //nolint:errorlint // we need to access methods of the aws error interface
78+
switch aerr.Code() {
79+
case iam.ErrCodeEntityAlreadyExistsException:
80+
return fmt.Errorf("IAM user %v already exists, use --user-name flag to override it", o.iamUser.userName)
81+
default:
82+
return err
83+
}
84+
}
7885
return err
7986
}
8087

0 commit comments

Comments
 (0)