Skip to content

Remove hard failure for not getting global STS endpoint #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions pkg/aws/ec2/api/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,23 @@ func (e *ec2Wrapper) getClientUsingAssumedRole(instanceRegion, roleARN, clusterN
// TODO: we should revisit the global sts endpoint and check if we should remove global endpoint
// we are not using it since the concern on availability and performance
// https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_enable-regions.html

globalSTSEndpoint, err := endpoints.DefaultResolver().
EndpointFor("sts", aws.StringValue(userStsSession.Config.Region))
if err != nil {
return nil, fmt.Errorf("failed to get the global sts endoint for region %s: %v",
*userStsSession.Config.Region, err)
}

// If the regional STS endpoint is different than the global STS endpoint then add the global sts endpoint
if regionalSTSEndpoint.URL != globalSTSEndpoint.URL {
globalProvider := &stscreds.AssumeRoleProvider{
Client: e.createSTSClient(userStsSession, client, regionalSTSEndpoint, sourceAcct, sourceArn),
RoleARN: roleARN,
Duration: time.Minute * 60,
e.log.Info("failed to get the global STS Endpoint, ignoring", "roleARN", roleARN)
} else {
// If the regional STS endpoint is different than the global STS endpoint then add the global sts endpoint
if regionalSTSEndpoint.URL != globalSTSEndpoint.URL {
globalProvider := &stscreds.AssumeRoleProvider{
Client: e.createSTSClient(userStsSession, client, regionalSTSEndpoint, sourceAcct, sourceArn),
RoleARN: roleARN,
Duration: time.Minute * 60,
}
providers = append(providers, globalProvider)
}
providers = append(providers, globalProvider)
}

e.log.Info("initialized the regional/global providers", "roleARN", roleARN)

userStsSession.Config.Credentials = credentials.NewChainCredentials(providers)
Expand Down
Loading