Skip to content

Commit d6f6162

Browse files
committed
Address PR feedback
1 parent 7636c42 commit d6f6162

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,12 @@ private RefreshResult<AwsCredentials> refreshCredentials() {
215215
return refreshCredentials();
216216
}
217217
} else {
218+
String profileName = resolveProfileName();
218219
throw SdkClientException.builder()
219-
.message("Invalid profile name")
220+
.message(String.format("Invalid EC2 instance profile name: '%s'. " +
221+
"Verify that the profile exists and that your instance " +
222+
"has permission to access it. ",
223+
profileName))
220224
.cause(e)
221225
.build();
222226
}

core/auth/src/test/java/software/amazon/awssdk/auth/credentials/InstanceProfileCredentialsProviderExtendedApiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void resolveCredentials_withInvalidProfileName_throwsError() {
271271

272272
assertThatThrownBy(() -> provider.resolveCredentials())
273273
.isInstanceOf(SdkClientException.class)
274-
.hasMessageContaining("Invalid profile name");
274+
.hasMessageContaining("Invalid EC2 instance profile name");
275275

276276
verify(putRequestedFor(urlPathEqualTo(TOKEN_RESOURCE_PATH))
277277
.withHeader(EC2_METADATA_TOKEN_TTL_HEADER, equalTo("21600")));
@@ -383,7 +383,7 @@ void resolveCredentials_withInvalidProfileNameAgainstLegacyApi_throwsError() {
383383

384384
assertThatThrownBy(() -> provider.resolveCredentials())
385385
.isInstanceOf(SdkClientException.class)
386-
.hasMessageContaining("Invalid profile name");
386+
.hasMessageContaining("Invalid EC2 instance profile name");
387387

388388
verify(putRequestedFor(urlPathEqualTo(TOKEN_RESOURCE_PATH))
389389
.withHeader(EC2_METADATA_TOKEN_TTL_HEADER, equalTo("21600")));

0 commit comments

Comments
 (0)