Search code examples
amazon-ecsaws-fargateamazon-ec2-spot-market

Running an aws ecs task in a region based on the cost of spot instances


I am recently experimenting with AWS and in particular the ECS service.

I have an application that runs tasks in a cluster and these tasks are launched via a lambda using boto3.

Wanting to reduce the cost of running the containers I was thinking of creating multiple clusters in different regions by setting FARGATE_SPOT as the capacity provider and then choosing the cluster in which to run the containers based on the lowest cost of the spot instances.

To control that cost and select the region accordingly I was thinking about the existence of an API that would allow me to do this in the lambda but I couldn't find anything in the documentation.

Would it be possible to do something like this ? If yes, is there an API to check the trend of the spot market in the various regions ?


Solution

  • Fargate spot pricing is not variable like EC2 spot pricing. There is no Fargate spot market like there is with EC2. There is no trending Fargate spot price like EC2. It is a set price, with the cheapest Fargate spot pricing always being in the US-EAST-2 Ohio region, followed by Oregon, then Virginia.