Skip to content

Commit c5e41b5

Browse files
committed
Address PR feedback:
Updating the debug logging message Modified the fallback logic in refresh credentials
1 parent e42ad38 commit c5e41b5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

.changes/next-release/feature-AWSEC2-9b178a4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"type": "feature",
33
"category": "AWS SDK for Java v2",
44
"contributor": "",
5-
"description": "EC2 IMDS Changes to Support Account ID"
5+
"description": "Include the account ID associated with the credentials retrieved from IMDS when available."
66
}

core/auth/src/main/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
177177
.prefetchTime(prefetchTime(expiration))
178178
.build();
179179
} catch (Ec2MetadataClientException e) {
180-
if (e.statusCode() == 404 && apiVersion.compareAndSet(ApiVersion.EXTENDED, ApiVersion.LEGACY)) {
181-
log.debug(() -> "Unable to load credential path from extended API. Falling back to legacy API.");
180+
if (e.statusCode() == 404) {
181+
log.debug(() -> "Resolved profile is no longer available. Resetting it and trying again.");
182182
resolvedProfile.set(null);
183183
return refreshCredentials();
184184
}
@@ -338,7 +338,7 @@ private String[] getSecurityCredentials(String imdsHostname, String metadataToke
338338

339339
} catch (Ec2MetadataClientException e) {
340340
if (e.statusCode() == 404 && apiVersion.compareAndSet(ApiVersion.UNKNOWN, ApiVersion.LEGACY)) {
341-
log.debug(() -> "Unable to load credential path from extended API. Falling back to legacy API.");
341+
log.debug(() -> "Instance does not support IMDS extended API. Falling back to legacy API.");
342342
return getSecurityCredentials(imdsHostname, metadataToken);
343343
}
344344
throw SdkClientException.create("Failed to load credentials from IMDS.", e);

0 commit comments

Comments
 (0)