The error “EC2 Error: Failed to Create Network Interface with Public IP in Subnet ‘subnet-id'” can occur when a Fargate task using the awsvpc network mode runs in a subnet with a public IP address, but the subnet lacks sufficient IP addresses. This situation arises because each Fargate task requires an available IP address from the subnet, and if the subnet is out of IP addresses, the task cannot launch, resulting in this error. To resolve this, you should increase the subnet’s IP address capacity or use a subnet with more available IP addresses.
Troubleshooting the Error
You can create a new subnet to run your task to resolve this issue.
Open the VPC Dashboard:
Step 1. Go to the AWS Management Console and navigate to the VPC service.
Create a New Subnet:
Step 1. In the VPC dashboard, click on Subnets from the left-hand menu.
Step 2. Click Create subnet.
Configure Subnet Settings:
Step 1. Select the VPC where you want to create the subnet.
Step 2. Specify a name for the subnet.
Step 3. Choose the Availability Zone for the subnet.
Step 4. Enter the CIDR block for the subnet (e.g., 10.0.1.0/24). This defines the range of IP addresses available in the subnet.
Enable Public IP Assignment (Optional):
If you want the subnet to automatically assign public IP addresses, check the Auto-assign public IPv4 address option.
Create the Subnet:
Step 1. Click Create Subnet to finalize the process.
Enable Public IP Assignment (Optional):
If you want the subnet to automatically assign public IP addresses, check the Auto-assign public IPv4 address option.
Create the Subnet:
Step 1. Click Create Subnet to finalize the process.
Update Route Tables (Optional):
If the subnet needs to access the internet, ensure it is associated with a route table with a route to an internet gateway.
Xieles experts help you to resolve problems related to subnet and other EC2 issues.!