Skip to content

feat: Add support for availability zone rebalancing (#262) #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
1 change: 1 addition & 0 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_alb_dns_name"></a> [alb\_dns\_name](#output\_alb\_dns\_name) | The DNS name of the load balancer |
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | ARN that identifies the cluster |
| <a name="output_cluster_autoscaling_capacity_providers"></a> [cluster\_autoscaling\_capacity\_providers](#output\_cluster\_autoscaling\_capacity\_providers) | Map of capacity providers created and their attributes |
| <a name="output_cluster_capacity_providers"></a> [cluster\_capacity\_providers](#output\_cluster\_capacity\_providers) | Map of cluster capacity providers attributes |
Expand Down
3 changes: 2 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ module "ecs" {
}
]

subnet_ids = module.vpc.private_subnets
subnet_ids = module.vpc.private_subnets
availability_zone_rebalancing = "ENABLED"
security_group_rules = {
alb_ingress_3000 = {
type = "ingress"
Expand Down
9 changes: 9 additions & 0 deletions examples/complete/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ output "services" {
description = "Map of services created and their attributes"
value = module.ecs.services
}

################################################################################
# Application Load Balancer
################################################################################

output "alb_dns_name" {
description = "The DNS name of the load balancer"
value = module.alb.dns_name
}
1 change: 1 addition & 0 deletions examples/ec2-autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ No inputs.

| Name | Description |
|------|-------------|
| <a name="output_alb_dns_name"></a> [alb\_dns\_name](#output\_alb\_dns\_name) | The DNS name of the load balancer |
| <a name="output_cluster_arn"></a> [cluster\_arn](#output\_cluster\_arn) | ARN that identifies the cluster |
| <a name="output_cluster_autoscaling_capacity_providers"></a> [cluster\_autoscaling\_capacity\_providers](#output\_cluster\_autoscaling\_capacity\_providers) | Map of capacity providers created and their attributes |
| <a name="output_cluster_capacity_providers"></a> [cluster\_capacity\_providers](#output\_cluster\_capacity\_providers) | Map of cluster capacity providers attributes |
Expand Down
5 changes: 3 additions & 2 deletions examples/fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ module "ecs_task_definition" {
source = "../../modules/service"

# Service
name = "${local.name}-standalone"
cluster_arn = module.ecs_cluster.arn
name = "${local.name}-standalone"
cluster_arn = module.ecs_cluster.arn
create_service = false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?


# Task Definition
volume = {
Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module "service" {
# Service
ignore_task_definition_changes = try(each.value.ignore_task_definition_changes, false)
alarms = try(each.value.alarms, {})
availability_zone_rebalancing = try(each.value.availability_zone_rebalancing, "DISABLED")
capacity_provider_strategy = try(each.value.capacity_provider_strategy, {})
cluster_arn = module.cluster.arn
deployment_circuit_breaker = try(each.value.deployment_circuit_breaker, {})
Expand Down
4 changes: 2 additions & 2 deletions modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,8 @@ resource "aws_iam_policy" "task_exec" {
name_prefix = var.task_exec_iam_role_use_name_prefix ? "${local.task_exec_iam_role_name}-" : null
description = coalesce(var.task_exec_iam_role_description, "Task execution role IAM policy")
policy = data.aws_iam_policy_document.task_exec[0].json

tags = merge(var.tags, var.task_exec_iam_role_tags)
path = var.task_exec_iam_policy_path
tags = merge(var.tags, var.task_exec_iam_role_tags)
}

resource "aws_iam_role_policy_attachment" "task_exec" {
Expand Down
12 changes: 12 additions & 0 deletions modules/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "availability_zone_rebalancing" {
default = null
}

variable "availability_zone_rebalancing" {
description = "Specifies whether to enable availability zone rebalancing"
type = string
default = "DISABLED"
}

variable "capacity_provider_strategy" {
description = "Capacity provider strategies to use for the service. Can be one or more"
type = map(object({
Expand Down Expand Up @@ -667,6 +673,12 @@ variable "task_exec_iam_statements" {
default = null
}

variable "task_exec_iam_policy_path" {
description = "Path for the iam role"
type = string
default = null
}

################################################################################
# Tasks - IAM role
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html
Expand Down
1 change: 1 addition & 0 deletions wrappers/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module "wrapper" {
}
}
})

autoscaling_scheduled_actions = try(each.value.autoscaling_scheduled_actions, var.defaults.autoscaling_scheduled_actions, null)
availability_zone_rebalancing = try(each.value.availability_zone_rebalancing, var.defaults.availability_zone_rebalancing, null)
capacity_provider_strategy = try(each.value.capacity_provider_strategy, var.defaults.capacity_provider_strategy, null)
Expand Down