Skip to content

Commit 3cc5e95

Browse files
committed
fix: Corrections
1 parent e987f75 commit 3cc5e95

File tree

16 files changed

+293
-214
lines changed

16 files changed

+293
-214
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

examples/complete/main.tf

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,18 @@ module "ecs" {
168168

169169
subnet_ids = module.vpc.private_subnets
170170
availability_zone_rebalancing = "ENABLED"
171-
security_group_rules = {
172-
alb_ingress_3000 = {
173-
type = "ingress"
174-
from_port = local.container_port
175-
to_port = local.container_port
176-
protocol = "tcp"
177-
description = "Service port"
178-
source_security_group_id = module.alb.security_group_id
171+
security_group_ingress_rules = {
172+
alb_3000 = {
173+
from_port = local.container_port
174+
description = "Service port"
175+
referenced_security_group_id = module.alb.security_group_id
179176
}
180-
egress_all = {
181-
type = "egress"
182-
from_port = 0
177+
}
178+
security_group_egress_rules = {
179+
all = {
180+
cidr_ipv4 = "0.0.0.0/0"
183181
to_port = 0
184-
protocol = "-1"
185-
cidr_blocks = ["0.0.0.0/0"]
182+
ip_protocol = "-1"
186183
}
187184
}
188185
}

examples/ec2-autoscaling/main.tf

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,10 @@ module "ecs_service" {
162162

163163
subnet_ids = module.vpc.private_subnets
164164
security_group_ingress_rules = {
165-
alb_http_ingress = {
166-
from_port = local.container_port
167-
protocol = "tcp"
168-
description = "Service port"
169-
source_security_group_id = module.alb.security_group_id
165+
alb_http = {
166+
from_port = local.container_port
167+
description = "Service port"
168+
referenced_security_group_id = module.alb.security_group_id
170169
}
171170
}
172171

@@ -261,7 +260,7 @@ module "autoscaling" {
261260
ex_1 = {
262261
instance_type = "t3.large"
263262
use_mixed_instances_policy = false
264-
mixed_instances_policy = {}
263+
mixed_instances_policy = null
265264
user_data = <<-EOT
266265
#!/bin/bash
267266
@@ -284,16 +283,18 @@ module "autoscaling" {
284283
spot_allocation_strategy = "price-capacity-optimized"
285284
}
286285

287-
override = [
288-
{
289-
instance_type = "m4.large"
290-
weighted_capacity = "2"
291-
},
292-
{
293-
instance_type = "t3.large"
294-
weighted_capacity = "1"
295-
},
296-
]
286+
launch_template = {
287+
override = [
288+
{
289+
instance_type = "m4.large"
290+
weighted_capacity = "2"
291+
},
292+
{
293+
instance_type = "t3.large"
294+
weighted_capacity = "1"
295+
},
296+
]
297+
}
297298
}
298299
user_data = <<-EOT
299300
#!/bin/bash

examples/fargate/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ module "ecs_service" {
6868
memory = 1024
6969
essential = true
7070
image = nonsensitive(data.aws_ssm_parameter.fluentbit.value)
71-
firelens_configuration = {
71+
firelensConfiguration = {
7272
type = "fluentbit"
7373
}
74-
memory_reservation = 50
75-
user = "0"
74+
memoryReservation = 50
75+
user = "0"
7676
}
7777

7878
(local.container_name) = {
7979
cpu = 512
8080
memory = 1024
8181
essential = true
8282
image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50"
83-
port_mappings = [
83+
portMappings = [
8484
{
8585
name = local.container_name
8686
containerPort = local.container_port
@@ -90,15 +90,15 @@ module "ecs_service" {
9090
]
9191

9292
# Example image used requires access to write to root filesystem
93-
readonly_root_filesystem = false
93+
readonlyRootFilesystem = false
9494

9595
dependencies = [{
9696
containerName = "fluent-bit"
9797
condition = "START"
9898
}]
9999

100100
enable_cloudwatch_logging = false
101-
log_configuration = {
101+
logConfiguration = {
102102
logDriver = "awsfirelens"
103103
options = {
104104
Name = "firehose"
@@ -108,7 +108,7 @@ module "ecs_service" {
108108
}
109109
}
110110

111-
linux_parameters = {
111+
linuxParameters = {
112112
capabilities = {
113113
add = []
114114
drop = [
@@ -117,19 +117,19 @@ module "ecs_service" {
117117
}
118118
}
119119

120-
restart_policy = {
120+
restartPolicy = {
121121
enabled = true
122122
ignoredExitCodes = [1]
123123
restartAttemptPeriod = 60
124124
}
125125

126126
# Not required for fluent-bit, just an example
127-
volumes_from = [{
127+
volumesFrom = [{
128128
sourceContainer = "fluent-bit"
129129
readOnly = false
130130
}]
131131

132-
memory_reservation = 100
132+
memoryReservation = 100
133133
}
134134
}
135135

@@ -157,15 +157,15 @@ module "ecs_service" {
157157

158158
subnet_ids = module.vpc.private_subnets
159159
security_group_ingress_rules = {
160-
alb_ingress_3000 = {
160+
alb_3000 = {
161161
description = "Service port"
162162
from_port = local.container_port
163163
ip_protocol = "tcp"
164164
referenced_security_group_id = module.alb.security_group_id
165165
}
166166
}
167167
security_group_egress_rules = {
168-
egress_all = {
168+
all = {
169169
ip_protocol = "-1"
170170
cidr_ipv4 = "0.0.0.0/0"
171171
}

modules/cluster/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ No modules.
174174
| <a name="input_cloudwatch_log_group_name"></a> [cloudwatch\_log\_group\_name](#input\_cloudwatch\_log\_group\_name) | Custom name of CloudWatch Log Group for ECS cluster | `string` | `null` | no |
175175
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | Number of days to retain log events | `number` | `90` | no |
176176
| <a name="input_cloudwatch_log_group_tags"></a> [cloudwatch\_log\_group\_tags](#input\_cloudwatch\_log\_group\_tags) | A map of additional tags to add to the log group created | `map(string)` | `{}` | no |
177-
| <a name="input_configuration"></a> [configuration](#input\_configuration) | The execute command configuration for the cluster | <pre>object({<br/> execute_command_configuration = optional(object({<br/> kms_key_id = optional(string)<br/> log_configuration = optional(object({<br/> cloud_watch_encryption_enabled = optional(bool)<br/> cloud_watch_log_group_name = optional(string)<br/> s3_bucket_encryption_enabled = optional(bool)<br/> s3_bucket_name = optional(string)<br/> s3_kms_key_id = optional(string)<br/> }))<br/> logging = optional(string, "OVERRIDE")<br/> }))<br/> managed_storage_configuration = optional(object({<br/> fargate_ephemeral_storage_kms_key_id = optional(string)<br/> kms_key_id = optional(string)<br/> }))<br/> })</pre> | <pre>{<br/> "execute_command_configuration": {<br/> "log_configuration": {<br/> "cloud_watch_log_group_name": "placeholder"<br/> }<br/> }<br/>}</pre> | no |
177+
| <a name="input_configuration"></a> [configuration](#input\_configuration) | The execute command configuration for the cluster | <pre>object({<br/> execute_command_configuration = optional(object({<br/> kms_key_id = optional(string)<br/> log_configuration = optional(object({<br/> cloud_watch_encryption_enabled = optional(bool)<br/> cloud_watch_log_group_name = optional(string)<br/> s3_bucket_encryption_enabled = optional(bool)<br/> s3_bucket_name = optional(string)<br/> s3_kms_key_id = optional(string)<br/> s3_key_prefix = optional(string)<br/> }))<br/> logging = optional(string, "OVERRIDE")<br/> }))<br/> managed_storage_configuration = optional(object({<br/> fargate_ephemeral_storage_kms_key_id = optional(string)<br/> kms_key_id = optional(string)<br/> }))<br/> })</pre> | <pre>{<br/> "execute_command_configuration": {<br/> "log_configuration": {<br/> "cloud_watch_log_group_name": "placeholder"<br/> }<br/> }<br/>}</pre> | no |
178178
| <a name="input_create"></a> [create](#input\_create) | Determines whether resources will be created (affects all resources) | `bool` | `true` | no |
179179
| <a name="input_create_cloudwatch_log_group"></a> [create\_cloudwatch\_log\_group](#input\_create\_cloudwatch\_log\_group) | Determines whether a log group is created by this module for the cluster logs. If not, AWS will automatically create one if logging is enabled | `bool` | `true` | no |
180180
| <a name="input_create_task_exec_iam_role"></a> [create\_task\_exec\_iam\_role](#input\_create\_task\_exec\_iam\_role) | Determines whether the ECS task definition IAM role should be created | `bool` | `false` | no |

modules/cluster/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ resource "aws_ecs_cluster_capacity_providers" "this" {
103103
cluster_name = aws_ecs_cluster.this[0].name
104104
capacity_providers = distinct(concat(
105105
[for k, v in var.default_capacity_provider_strategy : try(coalesce(v.name, k))],
106-
[for k, v in var.autoscaling_capacity_providers : try(coalesce(v.name, k))]
106+
var.autoscaling_capacity_providers != null ? [for k, v in var.autoscaling_capacity_providers : try(coalesce(v.name, k))] : []
107107
))
108108

109109
# https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-capacity-providers.html#capacity-providers-considerations
@@ -112,7 +112,7 @@ resource "aws_ecs_cluster_capacity_providers" "this" {
112112

113113
content {
114114
base = default_capacity_provider_strategy.value.base
115-
capacity_provider = default_capacity_provider_strategy.value.name
115+
capacity_provider = try(coalesce(default_capacity_provider_strategy.value.name, default_capacity_provider_strategy.key))
116116
weight = default_capacity_provider_strategy.value.weight
117117
}
118118
}

modules/cluster/variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ variable "configuration" {
3131
s3_bucket_encryption_enabled = optional(bool)
3232
s3_bucket_name = optional(string)
3333
s3_kms_key_id = optional(string)
34+
s3_key_prefix = optional(string)
3435
}))
3536
logging = optional(string, "OVERRIDE")
3637
}))

modules/container-definition/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ No modules.
182182
| <a name="input_resourceRequirements"></a> [resourceRequirements](#input\_resourceRequirements) | The type and amount of a resource to assign to a container. The only supported resource is a GPU | <pre>list(object({<br/> type = string<br/> value = string<br/> }))</pre> | `null` | no |
183183
| <a name="input_restartPolicy"></a> [restartPolicy](#input\_restartPolicy) | Container restart policy; helps overcome transient failures faster and maintain task availability | <pre>object({<br/> enabled = optional(bool, true)<br/> ignoredExitCodes = optional(list(number))<br/> restartAttemptPeriod = optional(number)<br/> })</pre> | <pre>{<br/> "enabled": true<br/>}</pre> | no |
184184
| <a name="input_secrets"></a> [secrets](#input\_secrets) | The secrets to pass to the container. For more information, see [Specifying Sensitive Data](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/specifying-sensitive-data.html) in the Amazon Elastic Container Service Developer Guide | <pre>list(object({<br/> name = string<br/> valueFrom = string<br/> }))</pre> | `null` | no |
185-
| <a name="input_service"></a> [service](#input\_service) | The name of the service that the container definition is associated with | `string` | `""` | no |
185+
| <a name="input_service"></a> [service](#input\_service) | The name of the service that the container definition is associated with. Used in CloudWatch log group default name (if one is not provided) | `string` | `null` | no |
186186
| <a name="input_startTimeout"></a> [startTimeout](#input\_startTimeout) | Time duration (in seconds) to wait before giving up on resolving dependencies for a container | `number` | `30` | no |
187187
| <a name="input_stopTimeout"></a> [stopTimeout](#input\_stopTimeout) | Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own | `number` | `120` | no |
188188
| <a name="input_systemControls"></a> [systemControls](#input\_systemControls) | A list of namespaced kernel parameters to set in the container | <pre>list(object({<br/> namespace = optional(string)<br/> value = optional(string)<br/> }))</pre> | `null` | no |

modules/container-definition/main.tf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ data "aws_region" "current" {
55
locals {
66
is_not_windows = contains(["LINUX"], var.operating_system_family)
77

8-
log_group_name = try(coalesce(var.cloudwatch_log_group_name, "/aws/ecs/${var.service}/${var.name}"), "")
8+
service = var.service != null ? "/${var.service}" : ""
9+
name = var.name != null ? "/${var.name}" : ""
10+
log_group_name = try(coalesce(var.cloudwatch_log_group_name, "/aws/ecs${local.service}${local.name}"), "")
911

1012
logConfiguration = merge(
1113
{

modules/container-definition/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ variable "workingDirectory" {
361361
################################################################################
362362

363363
variable "service" {
364-
description = "The name of the service that the container definition is associated with"
364+
description = "The name of the service that the container definition is associated with. Used in CloudWatch log group default name (if one is not provided)"
365365
type = string
366-
default = ""
366+
default = null
367367
}
368368

369369
variable "enable_cloudwatch_logging" {

0 commit comments

Comments
 (0)