I'm building an AWS VPC network lab via Terraform.
I want to add a NAT Gateway in order that my private network instances could access the internet for software updates.
From the Terraform spec you can see the an "allocation_id" is a required attribute:
allocation_id - (Required) The Allocation ID of the Elastic IP address for the gateway.
Checked also in AWS spec - In step 1:
A NAT gateway requires an Elastic IP address in your public subnet...
My question is: Why can't the NAT Gateway use a simple non static IPv4 address
?
What is the logic reason for that? (technically, it is the only option to configure).
Note: The question is in the scope of AWS, not Terraform.
Short Example for Nat Gateway config in Terraform:
resource "aws_nat_gateway" "natgw" {
allocation_id = "${(aws_eip.nateip.id)}"
subnet_id = "${(aws_subnet.public.id)}"
depends_on = ["aws_internet_gateway.igw"]
}