I have a single VPC in Amazon Web Services with the subnet 172.31.0.0/16. I have created an EC2 instance in this subnet and given it a public Elastic IP. There is an Internet Gateway on this VPC. So, my route table looks like this:
172.31.0.0/16 local 0.0.0.0/0 igw-b4ac67d0
In order to get around some IP access issues on an external service I do not control, I added a NAT gateway to this VPC so that all traffic to the single external address A.B.C.D would route through the NAT gateway. That is, I want the route table to look like this:
# GOAL 172.31.0.0/16 local A.B.C.D/32 nat-451b3be9 0.0.0.0/0 igw-b4ac67d0
However, try as I might, the AWS interface switches the order when I click "SAVE" so that I always end up with
# What AWS gives me 172.31.0.0/16 local 0.0.0.0/0 igw-b4ac67d0 A.B.C.D/32 nat-451b3be9
This route table seems silly: the NAT gateway would never get used and my traffic to
A.B.C.D still appears to be coming from the EC2 instance's Elastic IP.
How do I get the route table GOAL?
Note: The external service will allow me to add a single IP address that it will allow access. If I only had a single EC2 instance, I could simply give them the EC2 instance's Elastic IP address. But, I want to add several more EC2 instances set up the same way. Hence, the NAT gateway. Also, I cannot simply dispense with the Internet Gateway and use only the NAT gateway as I need services on the EC2 instance to be accessible by the outside world.