Skip to content

Commit dec0ddc

Browse files
committed
Try to reduce spot availability issues
Signed-off-by: Irving Popovetsky <[email protected]>
1 parent 5859253 commit dec0ddc

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

terraform/apps.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "aws_lb_listener_rule" "shutdown_sites_redirector" {
9393
"resources.operationcode.org",
9494
"resources-staging.operationcode.org",
9595
"api.operationcode.org",
96-
"backend-staging.operationcode.org",
96+
"backend.operationcode.org",
9797
"api.staging.operationcode.org",
9898
]
9999
}

terraform/asg.tf

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,39 @@ module "autoscaling" {
1010
version = "~> 6.5"
1111

1212
name = "${local.name}-spot"
13-
instance_type = "t3.small"
1413
min_size = 1
15-
max_size = 2
16-
desired_capacity = 1
17-
instance_market_options = {
18-
market_type = "spot"
14+
max_size = 4
15+
desired_capacity = 2
16+
17+
# Enable mixed instances policy
18+
use_mixed_instances_policy = true
19+
20+
# Mixed Instances Policy for better availability
21+
mixed_instances_policy = {
22+
instances_distribution = {
23+
on_demand_base_capacity = 0
24+
on_demand_percentage_above_base_capacity = 0
25+
spot_allocation_strategy = "capacity-optimized"
26+
}
27+
28+
override = [
29+
{
30+
instance_type = "t3.small"
31+
weighted_capacity = "2"
32+
},
33+
{
34+
instance_type = "t3a.small"
35+
weighted_capacity = "2"
36+
},
37+
{
38+
instance_type = "t3.micro"
39+
weighted_capacity = "1"
40+
},
41+
{
42+
instance_type = "t3a.micro"
43+
weighted_capacity = "1"
44+
}
45+
]
1946
}
2047

2148
image_id = jsondecode(data.aws_ssm_parameter.ecs_optimized_ami.value)["image_id"]

0 commit comments

Comments
 (0)