Skip to content

Commit

Permalink
Fix generating EKS token (#838)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
  • Loading branch information
mikkeloscar authored Jan 6, 2025
1 parent cb50574 commit 3ca2d0b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
8 changes: 4 additions & 4 deletions pkg/aws/eks/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package eks

import (
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
"golang.org/x/oauth2"
awsiamtoken "sigs.k8s.io/aws-iam-authenticator/pkg/token"
)
Expand All @@ -25,10 +26,9 @@ func (ts *TokenSource) Token() (*oauth2.Token, error) {
return nil, err
}

tokenOpts := &awsiamtoken.GetTokenOptions{
ClusterID: ts.clusterName,
}
awsToken, err := gen.GetWithOptions(tokenOpts)
stsAPI := sts.New(ts.session)

awsToken, err := gen.GetWithSTS(ts.clusterName, stsAPI)
if err != nil {
return nil, err
}
Expand Down
4 changes: 1 addition & 3 deletions provisioner/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ type (
acmClient acmiface.ACMAPI
eksClient eksiface.EKSAPI
region string
apiServer string
dryRun bool
logger *log.Entry
kmsClient kmsiface.KMSAPI
Expand All @@ -118,7 +117,7 @@ type (
)

// newAWSAdapter initializes a new awsAdapter.
func newAWSAdapter(logger *log.Entry, apiServer string, region string, sess *session.Session, dryRun bool) *awsAdapter {
func newAWSAdapter(logger *log.Entry, region string, sess *session.Session, dryRun bool) *awsAdapter {
return &awsAdapter{
session: sess,
cloudformationClient: cloudformation.New(sess),
Expand All @@ -130,7 +129,6 @@ func newAWSAdapter(logger *log.Entry, apiServer string, region string, sess *ses
acmClient: acm.New(sess),
eksClient: eks.New(sess),
region: region,
apiServer: apiServer,
dryRun: dryRun,
logger: logger,
kmsClient: kms.New(sess),
Expand Down
1 change: 0 additions & 1 deletion provisioner/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func newAWSAdapterWithStubs(status string, groupName string) *awsAdapter {
s3Uploader: &s3UploaderAPIStub{},
ec2Client: &ec2APIStub{},
autoscalingClient: &autoscalingAPIStub{groupName: groupName},
apiServer: "",
dryRun: false,
logger: logger,
}
Expand Down
2 changes: 1 addition & 1 deletion provisioner/clusterpy.go
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ func (p *clusterpyProvisioner) setupAWSAdapter(logger *log.Entry, cluster *api.C
return nil, err
}

adapter := newAWSAdapter(logger, cluster.APIServerURL, cluster.Region, sess, p.dryRun)
adapter := newAWSAdapter(logger, cluster.Region, sess, p.dryRun)
err = adapter.VerifyAccount(cluster.InfrastructureAccount)
if err != nil {
return nil, err
Expand Down

0 comments on commit 3ca2d0b

Please sign in to comment.