Table of Contents

The Error

Error creating EIP: AddressLimitExceeded: The maximum number of addresses has been reached

What Causes This

You’ve hit the AWS Elastic IP quota (default 5 per region). NAT Gateways, bastions, and public instances all consume EIPs.

How to Fix It

Solution 1: Release Unused EIPs

aws ec2 describe-addresses --query 'Addresses[?AssociationId==null].AllocationId' --output text | \
  xargs -n1 aws ec2 release-address --allocation-id

Solution 2: Request Quota Increase

aws service-quotas request-service-quota-increase \
  --service-code ec2 --quota-code L-0263D0A3 --desired-value 20

Solution 3: Use ALB Instead of Per-Instance EIPs

resource "aws_lb" "web" {
  load_balancer_type = "application"
  subnets            = aws_subnet.public[*].id
}

Prevention Tips

  1. Pin provider versions — avoid surprise breaking changes
  2. Use CI/CD — catch errors before they hit production
  3. Test with terraform plan — always review before applying
  4. Keep Terraform updated — newer versions have better error messages
  5. Use terraform validate — catches syntax errors early

Hands-On Courses

Conclusion

This error is common and fixable. Follow the solutions above, and check our Terraform course for hands-on training that covers real-world troubleshooting scenarios.