Skip to content

Commit

Permalink
Set up retries for assume role chain calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVulaj committed Jun 29, 2023
1 parent f4dfff7 commit 6804529
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/awsUtil/sts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"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"
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/aws/aws-sdk-go-v2/service/sts/types"
"github.com/openshift/backplane-cli/pkg/utils"
"net/http"
"net/url"
"time"
)

func StsClientWithProxy(proxyUrl string) (*sts.Client, error) {
Expand Down Expand Up @@ -107,6 +109,15 @@ func AssumeRoleSequence(roleSessionName string, seedClient STSRoleAssumer, roleA
},
},
}),
config.WithRetryer(func() aws.Retryer {
return retry.NewStandard(func(options *retry.StandardOptions) {
options.Retryables = append(options.Retryables, retry.RetryableHTTPStatusCode{
Codes: map[int]struct{}{401: {}, 403: {}, 404: {}}, // Handle IAM eventual consistency because backplane api modifies trust policy
})
options.MaxAttempts = 5
options.MaxBackoff = 20 * time.Second
})
}),
config.WithRegion("us-east-1"), // We don't care about region here, but the API still wants to see one set
)
if err != nil {
Expand Down

0 comments on commit 6804529

Please sign in to comment.