Fargate capacity providers is a new feature whereby you can set clusters and services to launch in EC2 spot capacity, enabling you to considerably cut costs by up to 70%.
resource "aws_ecs_cluster" "cluster" {
name = "cluster"
capacity_providers = ["FARGATE", "FARGATE_SPOT"]
default_capacity_provider_strategy {
capacity_provider {
name = "FARGATE"
weight = 5
base = 5
}
capacity_provider {
name = "FARGATE_SPOT"
weight = 1
base = 5
}
}
}
resource "aws_ecs_service" "service" {
name = "service"
# Other parameters cut for brevity
capacity_provider_strategy {
capacity_provider {
name = "FARGATE"
weight = 5
base = 5
}
capacity_provider {
name = "FARGATE_SPOT"
weight = 1
base = 5
}
}
}
When adding the capacity providers for the ecs_cluster
, there is also the EC2 capacity provider which takes a name, the ARN of an auto-scaling group, and some parameters around the capacity.
I was about to post an issue to add support for the ec2 ecs cluster auto-scaling and saw this issue that was very similar to it. Should I open an issue for the EC2 auto scaling or would it be a good idea to add it to this one?
https://aws.amazon.com/blogs/aws/aws-ecs-cluster-auto-scaling-is-now-generally-available/
@bflad Hi Brian. I just saw that this has been released. Could I implement this Fargate and EC2 Capacity Provider configuration?
@ryangardner the EC2 and Fargate Capacity providers look the same except that you need a new resource to create a Capacity provider for EC2 (so it's assigned to an ASG and has some config) and from what I've found out the capacity provider for Spot is already pre-created for all AWS accounts. So there is that extra resource that EC2 requires otherwise it's the same
Since there's already a pull request being worked on in https://github.com/terraform-providers/terraform-provider-aws/issues/11150 I'll close this to consolidate the discussion
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
When adding the capacity providers for the
ecs_cluster
, there is also the EC2 capacity provider which takes a name, the ARN of an auto-scaling group, and some parameters around the capacity.I was about to post an issue to add support for the ec2 ecs cluster auto-scaling and saw this issue that was very similar to it. Should I open an issue for the EC2 auto scaling or would it be a good idea to add it to this one?
https://aws.amazon.com/blogs/aws/aws-ecs-cluster-auto-scaling-is-now-generally-available/