Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
add retry to sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
roneli authored and yevgenypats committed Mar 4, 2021
1 parent 4a4f1b9 commit 7d1b34a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws/retry"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials/stscreds"
"github.com/aws/aws-sdk-go-v2/service/sts"
Expand Down Expand Up @@ -211,20 +212,20 @@ func (p *Provider) Fetch(data []byte) error {
RoleARN: "default",
})
}

retryOpt := config.WithRetryer(func() aws.Retryer {return retry.NewStandard()})
for _, account := range p.config.Accounts {
if account.ID != "default" && account.RoleARN != "" {
// assume role if specified (SDK takes it from default or env var: AWS_PROFILE)
p.cfg, err = config.LoadDefaultConfig(ctx)
p.cfg, err = config.LoadDefaultConfig(ctx, retryOpt)
if err != nil {
return err
}
p.cfg.Credentials = stscreds.NewAssumeRoleProvider(sts.NewFromConfig(p.cfg), account.RoleARN)

} else if account.ID != "default" {
p.cfg, err = config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile(account.ID))
p.cfg, err = config.LoadDefaultConfig(ctx, config.WithSharedConfigProfile(account.ID), retryOpt)
} else {
p.cfg, err = config.LoadDefaultConfig(ctx)
p.cfg, err = config.LoadDefaultConfig(ctx, retryOpt)
}
if err != nil {
return err
Expand Down

0 comments on commit 7d1b34a

Please sign in to comment.