Given that ipv6 is now supported in aws lambda, I have this code-
System.setProperty("java.net.preferIPv6Addresses", "true");
InetAddress ipAddress = Inet6Address.getByName("www.googleapis.com");
logger.info("ip is {}", ipAddress.getHostAddress());
and yet, the hostname is resolving to an ipv4. Note that I am deploying my function as an image with base public.ecr.aws/lambda/java:21
. When I run the code locally or on an ec2 instance, I see ipv6 address but on lambda, I see ipv4 address.
FWIW, I have also tried java runtime version 17 (as opposed to a docker image) but I still can't make lambda resolve to an ipv6 address.
Of course :) and I can see "Allow IPv6 traffic = true" in the VPC config of the lambda
The code below is in Python, but in that case I was able to obtain IPv6. Therefore, you can check the IPv6 address with Lambda as well.
Is IPv6 linked to VPC?