Skip to content

feat!: Work in progress for v6 #217

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

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1efb36d
feat: Support `managed_draining` argument at `aws_ecs_capacity_provid…
ivan-sukhomlyn Feb 12, 2024
83b79cd
feat: Add support for multiple `service`s inside `service_connect_con…
saki-engineering Feb 12, 2024
c83dc9e
feat: Add support for custom metric queries in customized_metric_spec…
mattaltberg May 31, 2024
73fce3c
feat: Add support for service connect timeout settings (#212)
salscode Jul 24, 2024
472aad9
feat: Add support for EBS volumes (#205)
rlinstorres Jul 24, 2024
12b2f40
feat: Add support for service connect tls settings (#216)
kevouellet Aug 5, 2024
bd6cffa
fix: Propagate support for EBS volumes to the root module (#223)
montaguethomas Sep 3, 2024
6bc8138
fix: Correct logic for local `needs_infrastructure_iam_role` check (#…
montaguethomas Sep 3, 2024
664bb44
feat: Add support for restartPolicy (#231)
psantus Sep 16, 2024
75f3e7d
refactor: Initial pass at variable type definitions for service module'
bryantbiggs Nov 22, 2024
4f98ff1
refactor: Initial pass at variable type definitions for container def…
bryantbiggs Nov 23, 2024
5d7c29e
chore: Update variable name to tag_specifications (#251)
LuisValdesZero Jan 9, 2025
fb5bcc4
feat: Add support for availability zone rebalancing (#262) (#269)
kskmats Mar 21, 2025
27d93bc
chore: Raise MSV of AWS provider
bryantbiggs Apr 1, 2025
4a0b133
feat: Use policy for tasks role instead of inline policy
bryantbiggs Apr 1, 2025
b0914fe
feat: Add FIS param and remove inference accelerator from `service` m…
bryantbiggs Apr 1, 2025
ed296d1
feat: Update cluster variable definitions; drop `cluster_` prefix
bryantbiggs Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
# - '--args=--only=terraform_naming_convention' # Disabled due to container definition variables requiring camelCase
- '--args=--only=terraform_required_version'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_standard_module_structure'
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ module "ecs" {

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.10 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.93 |

## Providers

Expand Down
6 changes: 3 additions & 3 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.10 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.93 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66.1 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.93 |

## Modules

Expand Down
31 changes: 23 additions & 8 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,33 @@ module "ecs" {
}
}
memory_reservation = 100

restart_policy = {
enabled = true
ignoredExitCodes = [1]
restartAttemptPeriod = 60
}
}
}

service_connect_configuration = {
namespace = aws_service_discovery_http_namespace.this.arn
service = {
client_alias = {
port = local.container_port
dns_name = local.container_name
service = [
{
client_alias = {
port = local.container_port
dns_name = local.container_name
}

timeout = {
idle_timeout_seconds = 20
per_request_timeout_seconds = 30
}

port_name = local.container_name
discovery_name = local.container_name
}
port_name = local.container_name
discovery_name = local.container_name
}
]
}

load_balancer = {
Expand All @@ -137,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
4 changes: 2 additions & 2 deletions examples/complete/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.0"
required_version = ">= 1.3.10"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.66.1"
version = ">= 5.93"
}
}
}
8 changes: 5 additions & 3 deletions examples/ec2-autoscaling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.10 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.93 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66.1 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.93 |

## Modules

Expand Down Expand Up @@ -74,6 +74,8 @@ No inputs.
| <a name="output_service_iam_role_name"></a> [service\_iam\_role\_name](#output\_service\_iam\_role\_name) | Service IAM role name |
| <a name="output_service_iam_role_unique_id"></a> [service\_iam\_role\_unique\_id](#output\_service\_iam\_role\_unique\_id) | Stable and unique string identifying the service IAM role |
| <a name="output_service_id"></a> [service\_id](#output\_service\_id) | ARN that identifies the service |
| <a name="output_service_infrastructure_iam_role_arn"></a> [service\_infrastructure\_iam\_role\_arn](#output\_service\_infrastructure\_iam\_role\_arn) | Infrastructure IAM role ARN |
| <a name="output_service_infrastructure_iam_role_name"></a> [service\_infrastructure\_iam\_role\_name](#output\_service\_infrastructure\_iam\_role\_name) | Infrastructure IAM role name |
| <a name="output_service_name"></a> [service\_name](#output\_service\_name) | Name of the service |
| <a name="output_service_task_definition_arn"></a> [service\_task\_definition\_arn](#output\_service\_task\_definition\_arn) | Full ARN of the Task Definition (including both `family` and `revision`) |
| <a name="output_service_task_definition_revision"></a> [service\_task\_definition\_revision](#output\_service\_task\_definition\_revision) | Revision of the task in a particular family |
Expand Down
28 changes: 23 additions & 5 deletions examples/ec2-autoscaling/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ locals {
module "ecs_cluster" {
source = "../../modules/cluster"

cluster_name = local.name
name = local.name

# Capacity provider - autoscaling groups
default_capacity_provider_use_fargate = false
autoscaling_capacity_providers = {
# On-demand instances
ex_1 = {
auto_scaling_group_arn = module.autoscaling["ex_1"].autoscaling_group_arn
managed_draining = "ENABLED"
managed_termination_protection = "ENABLED"

managed_scaling = {
Expand All @@ -53,6 +54,7 @@ module "ecs_cluster" {
# Spot instances
ex_2 = {
auto_scaling_group_arn = module.autoscaling["ex_2"].autoscaling_group_arn
managed_draining = "ENABLED"
managed_termination_protection = "ENABLED"

managed_scaling = {
Expand Down Expand Up @@ -93,8 +95,22 @@ module "ecs_service" {
}
}

volume_configuration = {
name = "ebs-volume"
managed_ebs_volume = {
encrypted = true
file_system_type = "xfs"
size_in_gb = 5
volume_type = "gp3"
}
}

volume = {
my-vol = {}
my-vol = {},
ebs-volume = {
name = "ebs-volume"
configure_at_launch = true
}
}

# Container definition(s)
Expand All @@ -113,6 +129,10 @@ module "ecs_service" {
{
sourceVolume = "my-vol",
containerPath = "/var/www/my-vol"
},
{
containerPath = "/ebs/data"
sourceVolume = "ebs-volume"
}
]

Expand Down Expand Up @@ -141,11 +161,9 @@ module "ecs_service" {
}

subnet_ids = module.vpc.private_subnets
security_group_rules = {
security_group_ingress_rules = {
alb_http_ingress = {
type = "ingress"
from_port = local.container_port
to_port = local.container_port
protocol = "tcp"
description = "Service port"
source_security_group_id = module.alb.security_group_id
Expand Down
10 changes: 10 additions & 0 deletions examples/ec2-autoscaling/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ output "service_autoscaling_scheduled_actions" {
value = module.ecs_service.autoscaling_scheduled_actions
}

output "service_infrastructure_iam_role_arn" {
description = "Infrastructure IAM role ARN"
value = module.ecs_service.infrastructure_iam_role_arn
}

output "service_infrastructure_iam_role_name" {
description = "Infrastructure IAM role name"
value = module.ecs_service.infrastructure_iam_role_name
}

################################################################################
# Application Load Balancer
################################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/ec2-autoscaling/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.0"
required_version = ">= 1.3.10"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.66.1"
version = ">= 5.93"
}
}
}
7 changes: 3 additions & 4 deletions examples/fargate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ Note that this example may create resources which will incur monetary charges on

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.66.1 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.10 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.93 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.66.1 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.93 |

## Modules

Expand Down Expand Up @@ -78,7 +78,6 @@ No inputs.
| <a name="output_service_security_group_id"></a> [service\_security\_group\_id](#output\_service\_security\_group\_id) | ID of the security group |
| <a name="output_service_task_definition_arn"></a> [service\_task\_definition\_arn](#output\_service\_task\_definition\_arn) | Full ARN of the Task Definition (including both `family` and `revision`) |
| <a name="output_service_task_definition_family"></a> [service\_task\_definition\_family](#output\_service\_task\_definition\_family) | The unique name of the task definition |
| <a name="output_service_task_definition_family_revision"></a> [service\_task\_definition\_family\_revision](#output\_service\_task\_definition\_family\_revision) | The family and revision (family:revision) of the task definition |
| <a name="output_service_task_definition_revision"></a> [service\_task\_definition\_revision](#output\_service\_task\_definition\_revision) | Revision of the task in a particular family |
| <a name="output_service_task_exec_iam_role_arn"></a> [service\_task\_exec\_iam\_role\_arn](#output\_service\_task\_exec\_iam\_role\_arn) | Task execution IAM role ARN |
| <a name="output_service_task_exec_iam_role_name"></a> [service\_task\_exec\_iam\_role\_name](#output\_service\_task\_exec\_iam\_role\_name) | Task execution IAM role name |
Expand Down
54 changes: 28 additions & 26 deletions examples/fargate/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ locals {
module "ecs_cluster" {
source = "../../modules/cluster"

cluster_name = local.name
name = local.name

# Capacity provider
fargate_capacity_providers = {
Expand Down Expand Up @@ -121,6 +121,12 @@ module "ecs_service" {
}
}

restart_policy = {
enabled = true
ignoredExitCodes = [1]
restartAttemptPeriod = 60
}

# Not required for fluent-bit, just an example
volumes_from = [{
sourceContainer = "fluent-bit"
Expand All @@ -133,14 +139,16 @@ module "ecs_service" {

service_connect_configuration = {
namespace = aws_service_discovery_http_namespace.this.arn
service = {
client_alias = {
port = local.container_port
dns_name = local.container_name
service = [
{
client_alias = {
port = local.container_port
dns_name = local.container_name
}
port_name = local.container_name
discovery_name = local.container_name
}
port_name = local.container_name
discovery_name = local.container_name
}
]
}

load_balancer = {
Expand All @@ -152,21 +160,18 @@ module "ecs_service" {
}

subnet_ids = module.vpc.private_subnets
security_group_rules = {
security_group_ingress_rules = {
alb_ingress_3000 = {
type = "ingress"
from_port = local.container_port
to_port = local.container_port
protocol = "tcp"
description = "Service port"
source_security_group_id = module.alb.security_group_id
description = "Service port"
from_port = local.container_port
ip_protocol = "tcp"
referenced_security_group_id = module.alb.security_group_id
}
}
security_group_egress_rules = {
egress_all = {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ip_protocol = "-1"
cidr_ipv4 = "0.0.0.0/0"
}
}

Expand Down Expand Up @@ -218,13 +223,10 @@ module "ecs_task_definition" {

subnet_ids = module.vpc.private_subnets

security_group_rules = {
security_group_egress_rules = {
egress_all = {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ip_protocol = "-1"
cidr_ipv4 = "0.0.0.0/0"
}
}

Expand Down
7 changes: 1 addition & 6 deletions examples/fargate/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ output "service_task_definition_family" {
value = module.ecs_service.task_definition_family
}

output "service_task_definition_family_revision" {
description = "The family and revision (family:revision) of the task definition"
value = module.ecs_service.task_definition_family_revision
}

output "service_task_exec_iam_role_name" {
description = "Task execution IAM role name"
value = module.ecs_service.task_exec_iam_role_name
Expand Down Expand Up @@ -159,7 +154,7 @@ output "task_definition_run_task_command" {
description = "awscli command to run the standalone task"
value = <<EOT
aws ecs run-task --cluster ${module.ecs_cluster.name} \
--task-definition ${module.ecs_task_definition.task_definition_family_revision} \
--task-definition ${module.ecs_task_definition.task_definition_family}:${module.ecs_task_definition.task_definition_revision} \
--network-configuration "awsvpcConfiguration={subnets=[${join(",", module.vpc.private_subnets)}],securityGroups=[${module.ecs_task_definition.security_group_id}]}" \
--region ${local.region}
EOT
Expand Down
4 changes: 2 additions & 2 deletions examples/fargate/versions.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
terraform {
required_version = ">= 1.0"
required_version = ">= 1.3.10"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.66.1"
version = ">= 5.93"
}
}
}
Loading