@@ -71,34 +71,37 @@ func newRoute53() (*Interface, error) {
71
71
region = imdsRegionResp .Region
72
72
}
73
73
74
- stsCfg , err := awsconfig .LoadDefaultConfig (ctx ,
75
- awsconfig .WithClientLogMode (aws .LogRetries ),
76
- awslog .WithAWSLogger (),
77
- awsconfig .WithRetryer (func () aws.Retryer {
78
- return retry .AddWithMaxAttempts (retry .NewStandard (), 5 )
79
- }),
80
- awsconfig .WithRegion (region ),
81
- )
82
- if err != nil {
83
- return nil , fmt .Errorf ("failed to load default aws config for STS client: %w" , err )
84
- }
85
-
86
74
awsOptions := []func (* awsconfig.LoadOptions ) error {
87
75
awsconfig .WithClientLogMode (aws .LogRetries ),
88
76
awslog .WithAWSLogger (),
89
77
awsconfig .WithRetryer (func () aws.Retryer {
90
78
return retry .AddWithMaxAttempts (retry .NewStandard (), 5 )
91
79
}),
92
- awsconfig .WithAssumeRoleCredentialOptions (func (aro * stscreds.AssumeRoleOptions ) {
93
- // Ensure the STS client has a region configured, if discovered by IMDS
94
- aro .Client = sts .NewFromConfig (stsCfg )
95
- }),
96
80
}
97
81
98
82
if imdsClient != nil {
99
- awsOptions = append (awsOptions , awsconfig .WithEC2IMDSRegion (func (o * awsconfig.UseEC2IMDSRegion ) {
100
- o .Client = imdsClient
101
- }))
83
+ stsCfg , err := awsconfig .LoadDefaultConfig (ctx ,
84
+ awsconfig .WithClientLogMode (aws .LogRetries ),
85
+ awslog .WithAWSLogger (),
86
+ awsconfig .WithRetryer (func () aws.Retryer {
87
+ return retry .AddWithMaxAttempts (retry .NewStandard (), 5 )
88
+ }),
89
+ awsconfig .WithRegion (region ),
90
+ )
91
+ if err != nil {
92
+ return nil , fmt .Errorf ("failed to load default aws config for STS client: %w" , err )
93
+ }
94
+
95
+ awsOptions = append (
96
+ awsOptions ,
97
+ awsconfig .WithEC2IMDSRegion (func (o * awsconfig.UseEC2IMDSRegion ) {
98
+ o .Client = imdsClient
99
+ }),
100
+ awsconfig .WithAssumeRoleCredentialOptions (func (aro * stscreds.AssumeRoleOptions ) {
101
+ // Ensure the STS client has a region configured, if discovered by IMDS
102
+ aro .Client = sts .NewFromConfig (stsCfg )
103
+ }),
104
+ )
102
105
}
103
106
104
107
cfg , err := awsconfig .LoadDefaultConfig (ctx , awsOptions ... )
0 commit comments