Skip to content

Getting the correct NetworkInterfaceAttachment when there is an associated EIP at an ENI at device index 1 #120

Closed
@JohnZucker

Description

Using AWS SDK 1.6.0.1 in a particular Vpc using instances, each with one attached ENI.

At approximately 12:00 UTC on Sunday 13 October, I saw two changes in the behaviour of requests to AmazonWebServices.

Change #1.
For as long as I can remember, GET http://169.254.169.254/latest/meta-data/public-ipv4 has returned a 404. I have never been clear on why this happened, because the actual behaviour seems to disagree with the doc at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html.
Nevertheless until 12:00 UTC yesterday GET http://169.254.169.254/latest/meta-data/local-ipv4 returned the IP address of the latest NIC to be attached. In the usual case, this will be at device 1 whenever an ENI is attached. Therefore, GET http://169.254.169.254/latest/meta-data/local-ipv4 returned the public IP address whenever I ran it prior to 12:00 UTC yesterday. I found this useful, even though it seems to disagree with the doc yet again. But after 12:00 UTC it returns the internal IP address, so reversing this previous feature.
There no longer appears to be a viable way of discovering the public IP address from the hypervisor.

Change #2.
The response to the getAssociation() method of NetworkInterface does not seem to be the same as in previous runs for all week. Previously the following code returned a non-empy association when passed in the instanceId of an instance with an attached ENI which had an EIP associated to it.

Here is a code fragment. The final entry now returns null.

public void assocTest() {
List listOfInstanceId = Arrays.asList(instanceId);
DescribeNetworkInterfacesRequest networkInterfacesRequest = new DescribeNetworkInterfacesRequest()
.withFilters(new Filter("attachment.instance-id", listOfInstanceId));
List networkInterfaces = ec2.describeNetworkInterfaces(networkInterfacesRequest)
.getNetworkInterfaces();
if (networkInterfaces.size() > 0) {
NetworkInterface networkInterface = networkInterfaces.get(0);
NetworkInterfaceAttachment networkInterfaceAttachment = networkInterface.getAttachment();
NetworkInterfaceAssociation networkInterfaceAssociation = networkInterface.getAssociation();
System.out.println("networkInterface " + networkInterface);
System.out.println("networkInterfaceAttachment " + networkInterfaceAttachment);
System.out.println("networkInterfaceAssociation " + networkInterfaceAssociation);
}
}

Although this behaviour seems to have changed, the result on the commandline of ec2din $instanceId still returns a NICASSOCIATION with the public IP.

Please help explain what has changed. Why is a valid NetworkInterfaceAssociation object no longer returned?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions