AWS Portal Elastic IP Issue

Hello!

We are setting up AWS Portal and we need to whitelist the gateway EC2 which is attached to an EIP. The EIP is being deleted by Cloudformation when deleting the infrastructure which is to be expected since that is what CF is designed for. The issue this is causing for us is that we need to whitelist that EIP address every time we need to spin up the infrastructure. If we were panning on leaving the infrastructure up all the time, this would be fine. But we want to only spin up when needed and then shut it down when we don’t need it. The only work around I can think of is to reserve an EIP and then manually attach that to the gateway EC2 on launch every time we need to spin up the infrastructure. Then we can whitelist the EIP once on our firewall. This is not ideal since we would rather not have to log into the console to do this or make a make a script to automate the attaching of the EIP every time. I also know that unattached EIP’s do have a cost, so how are we expected to handle this?

Any suggestions would be great.