How To Fix AWS ECS Registration Failures on IPv6-Only EC2 Instances

How to Fix AWS Quick Data Preview Issue for Iceberg Tables in Athena

Written by

in

If you’re running your Amazon ECS instance in an IPv6-only environment and facing connection issues, the problem might be because the ECS container agent isn’t configured to recognize that mode. By default, the agent tries to automatically detect whether the instance uses IPv4 or IPv6 by checking the network routes, but this method can fail in IPv6-only setups.

The best way to fix this is to explicitly tell the ECS agent that your instance is in IPv6-only mode. You can do this by setting a specific parameter in your user data script when launching the instance. Here’s how you can do it:

Start your script with the following content. It sets the ECS_INSTANCE_IP_COMPATIBILITY parameter to ipv6:

bash

!/bin/bash

cat <<‘EOF’ >> /etc/ecs/ecs.config
ECS_CLUSTER=your-cluster-name
ECS_INSTANCE_IP_COMPATIBILITY=ipv6
EOF

Replace "your-cluster-name" with the name of your ECS cluster. This configuration ensures that the ECS agent uses IPv6 for registration and communication.

In addition to updating your user data, double-check that:

  • Your ECS container agent version is 1.99.1 or newer. You can confirm this by checking your AMI.
  • The security groups attached to the instance allow IPv6 traffic for ECS agent communication.
  • If your containers need to connect to IPv4-only services, make sure you have DNS64 and NAT64 correctly set up in your Virtual Private Cloud (VPC).
  • When pulling images from Amazon Elastic Container Registry (ECR), use dual-stack image endpoints to support both IPv4 and IPv6.

The main thing is setting the ECS_INSTANCE_IP_COMPATIBILITY parameter to ipv6. This step is usually the key to resolving registration problems in IPv6-only environments.

References:

  • Amazon ECS task networking options for EC2
  • Bootstrapping Amazon ECS Linux container instances