Search code examples
amazon-web-servicesamazon-ecs

AWS ECS with spot instance and static ip


I have a container that runs Flask which I’ve deployed on a spot EC2 instance. I used route53 to assign a dns to that server so all the clients that talk to it just use that dns.

When the spot instance goes down it’s not that big of a deal. This is not mission critical work, so I just create a new instance and then update route53 with the new ip address.

I recently just started using ECS to launch the container and it’s been great to have the logging on CloudWatch and the health monitoring.

Is there some configuration where I can use ECS with spot with auto-restart but have a static ip (or dns) for the clients?

I’m a bit lost in the candy store at the moment. Any pointers would be awesome.


Solution

  • Elastic Network Interface (ENI) will help acomplish this requirement of assigning pre-defined static IP address to the spot instance.

    The IP address can be configured to an elastic network interface. The interface can then be attached to any EC2 instance (including spot instance).

    More information on ENI:

    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html