Skip to content

Issue Using CodeDeploy with EC2 without public IPv4 address

0

Hi there,

I'm attempting to use CodeDeploy to send my application code to an EC2 instance I have running in VPC I created. This VPC assigns IPv6 addresses and I am trying to avoid using public IPv4 addresses as much as possible. The VPC does have an internet gateway that the public subnets can access, and my EC2 instance is on one of these subnets.

I was able to successfully install the CodeDeploy agent onto the machine using the install script, although I had to add 'dualstack' to the s3 link to wget the install script, and I had to modify the s3 call within the script to use 'dualstack' as well when it downloaded the agent files.

I was also able to successfully install ruby and the dotnet runtime using apt-get.

However, when running the CodeDeploy process, the agent on the EC2 instance has the following in the log file,

2025-07-11T01:17:02 ERROR [codedeploy-agent(1932)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl: Error during certificate verification on codedeploy endpoint https://codedeploy-commands.us-west-1.amazonaws.com
2025-07-11T01:17:02 DEBUG [codedeploy-agent(1932)]: InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl: #<Net::OpenTimeout: Failed to open TCP connection to codedeploy-commands.us-west-1.amazonaws.com:443 (execution expired)>
2025-07-11T01:17:02 ERROR [codedeploy-agent(1932)]: Error validating the SSL configuration: Invalid server certificate
2025-07-11T01:17:02 ERROR [codedeploy-agent(1932)]: booting child: error during start or run: SystemExit - Stopping CodeDeploy agent due to SSL validation error. - /opt/codedeploy-agent/lib/instance_agent/plugins/codedeploy/command_poller.rb:65:in `abort'

According to the DEBUG line, it is unable to access codedeploy-commands.us-west-1.amazonaws.com via HTTPS. My security group for the VPC has outgoing connections for IPv4 and IPv6 wide open.

Why is the agent on my instance unable to access the codedeploy endpoint?

Thanks!

asked a year ago228 views

2 Answers
0
Accepted Answer

I've answered my question. Yes, using a "dualstack" configuration means assigning a public IPv4 address in addition to the IPv6 address. This is ultimately the route I went down, and once CodeDeploy is made to work with IPv6 only, I will remove the IPv4 and things should continue to work.

The NAT Gateway w/ NAT64 and DNS64 functionality solution is relatively expensive compared to using public IPv4 addresses.

answered a year ago

0

The issue you're experiencing is because the AWS CodeDeploy agent does not currently support IPv6 communication. Even though you've set up your VPC with IPv6 addresses and have an internet gateway configured, the CodeDeploy agent can only communicate over IPv4.

To resolve this issue, you need to configure your instances to use both IPv4 and IPv6 addresses (dual-stack mode). This will allow the CodeDeploy agent to communicate over IPv4 while the rest of your application can use IPv6 addresses.

The error message you're seeing indicates that the CodeDeploy agent is trying to connect to the CodeDeploy service endpoint (codedeploy-commands.us-west-1.amazonaws.com) but is unable to establish a connection because it's attempting to use IPv6 while the agent only supports IPv4.

For IPv6-only instances that need to communicate with IPv4-only destinations (like the CodeDeploy service), you would typically need to implement NAT64 and DNS64 functionality using an Amazon VPC NAT Gateway. This allows IPv6-only instances to communicate with IPv4-only destinations by translating IPv6 packets to IPv4 and synthesizing AAAA records for IPv4-only destinations.

However, in this specific case, the simplest solution is to assign a public IPv4 address to your EC2 instance or use a dual-stack configuration to allow the CodeDeploy agent to function properly.
Sources
Migration issue from ipv4 to ipv6 | AWS re:Post
EC2 instances cannot reach IPv4 in dualstack VPC | AWS re:Post

answered a year ago

  • Does using a dualstack configuration mean assigning both a public IPv4 and public IPv6 address at the same time? Or is it not about having a public IPv4 and my EC2 instance just needs a private IPv4? I thought it had one by default but I'm not very competent in network configuration.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.