Skip to content

Commit

Permalink
chore: added RoleSessionName and assume role duration
Browse files Browse the repository at this point in the history
Signed-off-by: minhthong582000 <[email protected]>
  • Loading branch information
minhthong582000 committed Sep 5, 2023
1 parent 9e854f8 commit e1f97f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package aws
import (
"context"
"log"
"time"

"github.com/armory-io/eks-auto-updater/pkg/aws/eks"
"github.com/armory-io/eks-auto-updater/pkg/aws/options"
Expand Down Expand Up @@ -38,7 +39,10 @@ func NewClient(ctx context.Context, opts ...options.Option) (Client, error) {

if len(AWSRoleArn) != 0 {
stsClient := sts.NewFromConfig(cfg)
provider := stscreds.NewAssumeRoleProvider(stsClient, AWSRoleArn)
provider := stscreds.NewAssumeRoleProvider(stsClient, AWSRoleArn, func(o *stscreds.AssumeRoleOptions) {
o.RoleSessionName = "eks-auto-updater"
o.Duration = time.Duration(60 * time.Minute)
})
cfg.Credentials = aws.NewCredentialsCache(provider)

log.Println("INFO: Assuming role ARN " + AWSRoleArn)
Expand Down

0 comments on commit e1f97f1

Please sign in to comment.