@@ -121,17 +121,22 @@ func CreateAwsConfig(
121
121
return aws.Config {}, errors .Errorf ("Error loading AWS config: %w" , err )
122
122
}
123
123
124
- iamRoleOptions := getMergedIAMRoleOptions (awsCfg , opts )
125
- if iamRoleOptions .RoleARN != "" {
126
- if iamRoleOptions .WebIdentityToken != "" {
127
- l .Debugf ("Assuming role %s using WebIdentity token" , iamRoleOptions .RoleARN )
128
-
129
- cfg .Credentials = getWebIdentityCredentialsFromIAMRoleOptions (cfg , iamRoleOptions )
130
- } else {
131
- l .Debugf ("Assuming role %s" , iamRoleOptions .RoleARN )
132
-
133
- cfg .Credentials = getSTSCredentialsFromIAMRoleOptions (cfg , iamRoleOptions , getExternalID (awsCfg ))
124
+ envCreds := createCredentialsFromEnv (opts )
125
+ if envCreds == nil {
126
+ iamRoleOptions := getMergedIAMRoleOptions (awsCfg , opts )
127
+ if iamRoleOptions .RoleARN != "" {
128
+ if iamRoleOptions .WebIdentityToken != "" {
129
+ l .Debugf ("Assuming role %s using WebIdentity token" , iamRoleOptions .RoleARN )
130
+
131
+ cfg .Credentials = getWebIdentityCredentialsFromIAMRoleOptions (cfg , iamRoleOptions )
132
+ } else {
133
+ l .Debugf ("Assuming role %s" , iamRoleOptions .RoleARN )
134
+
135
+ cfg .Credentials = getSTSCredentialsFromIAMRoleOptions (cfg , iamRoleOptions , getExternalID (awsCfg ))
136
+ }
134
137
}
138
+ } else {
139
+ l .Debugf ("Skipping role assumption as credentials are already available from auth provider command" )
135
140
}
136
141
137
142
return cfg , nil
0 commit comments