Skip to content

Commit a667cd1

Browse files
authored
Remove hard failure for not getting global STS endpoint (#467)
1 parent 19ed9ef commit a667cd1

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg/aws/ec2/api/wrapper.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -537,22 +537,23 @@ func (e *ec2Wrapper) getClientUsingAssumedRole(instanceRegion, roleARN, clusterN
537537
// TODO: we should revisit the global sts endpoint and check if we should remove global endpoint
538538
// we are not using it since the concern on availability and performance
539539
// https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html
540+
540541
globalSTSEndpoint, err := endpoints.DefaultResolver().
541542
EndpointFor("sts", aws.StringValue(userStsSession.Config.Region))
542543
if err != nil {
543-
return nil, fmt.Errorf("failed to get the global sts endoint for region %s: %v",
544-
*userStsSession.Config.Region, err)
545-
}
546-
547-
// If the regional STS endpoint is different than the global STS endpoint then add the global sts endpoint
548-
if regionalSTSEndpoint.URL != globalSTSEndpoint.URL {
549-
globalProvider := &stscreds.AssumeRoleProvider{
550-
Client: e.createSTSClient(userStsSession, client, regionalSTSEndpoint, sourceAcct, sourceArn),
551-
RoleARN: roleARN,
552-
Duration: time.Minute * 60,
544+
e.log.Info("failed to get the global STS Endpoint, ignoring", "roleARN", roleARN)
545+
} else {
546+
// If the regional STS endpoint is different than the global STS endpoint then add the global sts endpoint
547+
if regionalSTSEndpoint.URL != globalSTSEndpoint.URL {
548+
globalProvider := &stscreds.AssumeRoleProvider{
549+
Client: e.createSTSClient(userStsSession, client, regionalSTSEndpoint, sourceAcct, sourceArn),
550+
RoleARN: roleARN,
551+
Duration: time.Minute * 60,
552+
}
553+
providers = append(providers, globalProvider)
553554
}
554-
providers = append(providers, globalProvider)
555555
}
556+
556557
e.log.Info("initialized the regional/global providers", "roleARN", roleARN)
557558

558559
userStsSession.Config.Credentials = credentials.NewChainCredentials(providers)

0 commit comments

Comments
 (0)