Skip to content

Commit

Permalink
Merge pull request #10 from juam-veras/master
Browse files Browse the repository at this point in the history
feat(ECS): without_capacity_provider
  • Loading branch information
brunodasilvalenga authored Jan 30, 2024
2 parents 4dc2e28 + 7aea523 commit 357a39c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ In addition you have the option to create or not :
| subnets | The subnets associated with the task or service. (REQUIRED IF 'LAUCH\_TYPE' IS FARGATE) | `any` | `null` | no |
| task\_role\_arn | Existing task role ARN created by ECS cluster module | `any` | n/a | yes |
| vpc\_id | VPC ID to deploy this app to | `any` | n/a | yes |
| without\_capacity\_provider | Launch service without capacity provider | `bool` | n/a | no |

## Outputs

Expand Down
5 changes: 5 additions & 0 deletions _variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,9 @@ variable "network_mode" {
variable "security_groups" {
default = null
description = "The security groups associated with the task or service"
}

variable "without_capacity_provider" {
default = false
description = "Launch service without capacity provider"
}
11 changes: 7 additions & 4 deletions ecs-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ resource "aws_ecs_service" "default" {
}
}

capacity_provider_strategy {
capacity_provider = var.launch_type == "FARGATE" ? (var.fargate_spot ? "FARGATE_SPOT" : "FARGATE") : "${var.cluster_name}-capacity-provider"
weight = 1
base = 0
dynamic "capacity_provider_strategy" {
for_each = try(var.without_capacity_provider,false) ? [] : ["1"]
content {
capacity_provider = var.launch_type == "FARGATE" ? (var.fargate_spot ? "FARGATE_SPOT" : "FARGATE") : "${var.cluster_name}-capacity-provider"
weight = 1
base = 0
}
}

lifecycle {
Expand Down

0 comments on commit 357a39c

Please sign in to comment.