Skip to content

Commit

Permalink
Add support to Fargate Spot
Browse files Browse the repository at this point in the history
  • Loading branch information
emyller committed Jun 17, 2022
1 parent 9b9df89 commit 162168b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions _vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,9 @@ variable "extra_security_groups" {
type = list(string)
default = []
}

variable "use_spot" {
description = "Use Fargate Spot instead of Fargate. EC2 not supported yet."
type = bool
default = false
}
6 changes: 5 additions & 1 deletion cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ resource "aws_ecs_cluster_capacity_providers" "fargate" {
EC2 capacity provider
*/
cluster_name = aws_ecs_cluster.main.name
capacity_providers = ["FARGATE"]
capacity_providers = [var.use_spot ? "FARGATE_SPOT" : "FARGATE"]

default_capacity_provider_strategy {
capacity_provider = var.use_spot ? "FARGATE_SPOT" : "FARGATE"
}
}

resource "aws_ecs_cluster_capacity_providers" "ec2" {
Expand Down

0 comments on commit 162168b

Please sign in to comment.