Table of Contents
The Error
Error creating NAT Gateway: NotFound: Elastic IP address not found
What Causes This
The Elastic IP referenced doesn’t exist, the subnet is private (needs to be public), or connectivity type is misconfigured.
How to Fix It
Solution 1: Create EIP First
resource "aws_eip" "nat" {
domain = "vpc"
}
resource "aws_nat_gateway" "main" {
allocation_id = aws_eip.nat.id
subnet_id = aws_subnet.public.id # Must be PUBLIC subnet!
}
Solution 2: Use Public Subnet
# NAT Gateway must be in a public subnet with IGW route
resource "aws_subnet" "public" {
vpc_id = aws_vpc.main.id
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = true
}
Solution 3: Private NAT Gateway (No EIP)
resource "aws_nat_gateway" "private" {
connectivity_type = "private" # No EIP needed
subnet_id = aws_subnet.private.id
}
Prevention Tips
- Pin provider versions — avoid surprise breaking changes
- Use CI/CD — catch errors before they hit production
- Test with
terraform plan— always review before applying - Keep Terraform updated — newer versions have better error messages
- Use
terraform validate— catches syntax errors early
Hands-On Courses
- Terraform for Beginners on CopyPasteLearn
- Terraform By Example — practical code examples
- Terraform Cheat Sheet — quick reference for all commands
Related Articles
- Terraform Troubleshooting - Common Errors and Solutions
- Terraform Enabling and Using Debugging
- Debugging with TFLint
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.

