Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ private boolean matchesAllowedHostRules(InetAddress inetAddress) {
}

public boolean isMetadataServiceEndpoint(String host) {
String mode = SdkSystemSetting.AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE.getStringValueOrThrow();
if ("IPV6".equalsIgnoreCase(mode)) {
return VALID_LOOP_BACK_IPV6.contains(host);
}
return VALID_LOOP_BACK_IPV4.contains(host);
return VALID_LOOP_BACK_IPV4.contains(host) || VALID_LOOP_BACK_IPV6.contains(host);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,20 @@ private static Stream<Arguments> requestConstruction() {
.headers(new HashMap<>())
.build())),

// EKS Pod Identity sets the IPv6 container URI but does NOT set
// AWS_EC2_METADATA_SERVICE_ENDPOINT_MODE (that controls IMDS, not the
// container credentials endpoint). The IPv6 host must be allowed with the
// mode left at its IPv4 default.
Arguments.of("http link-local EKS URI with IPv6, default endpoint mode",
Collections.singletonList(Pair.of(FULL_URI_ENV, EKS_CONTAINER_HOST_IPV6 + "/credentials")),
EKS_CONTAINER_HOST_IPV6 + "/credentials",
new Result().type("success").sdkRequest(
SdkHttpFullRequest.builder()
.uri(URI.create(EKS_CONTAINER_HOST_IPV6 + "/credentials"))
.method(SdkHttpMethod.GET)
.headers(new HashMap<>())
.build())),

Arguments.of("complex full URI",
Collections.singletonList(Pair.of(FULL_URI_ENV, COMPLEX_URI)),
COMPLEX_URI,
Expand Down