Skip to content

Commit f3c9f66

Browse files
committed
fix: Corrections
1 parent e987f75 commit f3c9f66

File tree

19 files changed

+612
-381
lines changed

19 files changed

+612
-381
lines changed

README.md

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

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,20 +321,20 @@ The default behavior of the container definition module is to create the CloudWa
321321
# FluentBit sidecar is required for Firelens
322322
fluent-bit = {
323323
image = data.aws_ssm_parameter.fluentbit.value
324-
firelens_configuration = {
324+
firelensConfiguration = {
325325
type = "fluentbit"
326326
}
327327
# ...
328328
}
329329
330330
default = {
331-
dependencies = [{
331+
dependsOn = [{
332332
containerName = "fluent-bit"
333333
condition = "START"
334334
}]
335335
336336
enable_cloudwatch_logging = false
337-
log_configuration = {
337+
logConfiguration = {
338338
logDriver = "awsfirelens"
339339
options = {
340340
# ...

docs/UPGRADE-6.0.md

Lines changed: 183 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,202 @@ module "ecs" {
5555
5656
# Truncated for brevity ...
5757
58+
# Container definition(s)
59+
container_definitions = {
60+
61+
fluent-bit = {
62+
cpu = 512
63+
memory = 1024
64+
essential = true
65+
image = "public.ecr.aws/aws-observability/aws-for-fluent-bit:stable"
66+
firelens_configuration = {
67+
type = "fluentbit"
68+
}
69+
memory_reservation = 50
70+
user = "0"
71+
}
72+
73+
ecsdemo-frontend = {
74+
cpu = 512
75+
memory = 1024
76+
essential = true
77+
image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50"
78+
port_mappings = [
79+
{
80+
name = ecsdemo-frontend
81+
containerPort = 3000
82+
hostPort = 3000
83+
protocol = "tcp"
84+
}
85+
]
86+
87+
# Example image used requires access to write to root filesystem
88+
readonly_root_filesystem = false
89+
90+
dependencies = [{
91+
containerName = "fluent-bit"
92+
condition = "START"
93+
}]
94+
95+
enable_cloudwatch_logging = false
96+
log_configuration = {
97+
logDriver = "awsfirelens"
98+
options = {
99+
Name = "firehose"
100+
region = local.region
101+
delivery_stream = "my-stream"
102+
log-driver-buffer-limit = "2097152"
103+
}
104+
}
105+
106+
linux_parameters = {
107+
capabilities = {
108+
add = []
109+
drop = [
110+
"NET_RAW"
111+
]
112+
}
113+
}
114+
115+
# Not required for fluent-bit, just an example
116+
volumes_from = [{
117+
sourceContainer = "fluent-bit"
118+
readOnly = false
119+
}]
120+
121+
memory_reservation = 100
122+
}
123+
}
124+
125+
security_group_rules = {
126+
alb_ingress_3000 = {
127+
type = "ingress"
128+
from_port = 3000
129+
description = "Service port"
130+
source_security_group_id = module.alb.security_group_id
131+
}
132+
egress_all = {
133+
type = "egress"
134+
from_port = 0
135+
to_port = 0
136+
protocol = "-1"
137+
cidr_blocks = ["0.0.0.0/0"]
138+
}
139+
}
58140
}
59141
```
60142

61143
### After 6.x Example
62144

145+
#### Service
146+
63147
```hcl
64148
module "ecs" {
65-
source = "terraform-aws-modules/ecs/aws"
149+
source = "terraform-aws-modules/ecs/aws//modules/service"
66150
version = "~> 6.0"
67151
68152
# Truncated for brevity ...
69153
154+
# Container definition(s)
155+
container_definitions = {
156+
157+
fluent-bit = {
158+
cpu = 512
159+
memory = 1024
160+
essential = true
161+
image = "public.ecr.aws/aws-observability/aws-for-fluent-bit:stable"
162+
firelensConfiguration = {
163+
type = "fluentbit"
164+
}
165+
memoryReservation = 50
166+
user = "0"
167+
}
168+
169+
ecsdemo-frontend = {
170+
cpu = 512
171+
memory = 1024
172+
essential = true
173+
image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50"
174+
portMappings = [
175+
{
176+
name = "ecsdemo-frontend"
177+
containerPort = 3000
178+
hostPort = 3000
179+
protocol = "tcp"
180+
}
181+
]
182+
183+
# Example image used requires access to write to root filesystem
184+
readonlyRootFilesystem = false
185+
186+
dependsOn = [{
187+
containerName = "fluent-bit"
188+
condition = "START"
189+
}]
190+
191+
enable_cloudwatch_logging = false
192+
logConfiguration = {
193+
logDriver = "awsfirelens"
194+
options = {
195+
Name = "firehose"
196+
region = local.region
197+
delivery_stream = "my-stream"
198+
log-driver-buffer-limit = "2097152"
199+
}
200+
}
201+
202+
linuxParameters = {
203+
capabilities = {
204+
add = []
205+
drop = [
206+
"NET_RAW"
207+
]
208+
}
209+
}
210+
211+
restartPolicy = {
212+
enabled = true
213+
ignoredExitCodes = [1]
214+
restartAttemptPeriod = 60
215+
}
216+
217+
# Not required for fluent-bit, just an example
218+
volumesFrom = [{
219+
sourceContainer = "fluent-bit"
220+
readOnly = false
221+
}]
222+
223+
memoryReservation = 100
224+
}
225+
}
226+
227+
security_group_ingress_rules = {
228+
alb_3000 = {
229+
description = "Service port"
230+
from_port = 3000
231+
referenced_security_group_id = module.alb.security_group_id
232+
}
233+
}
234+
security_group_egress_rules = {
235+
all = {
236+
ip_protocol = "-1"
237+
cidr_ipv4 = "0.0.0.0/0"
238+
}
239+
}
70240
}
71241
```
72242

73243
### State Changes
74244

75-
TODO
245+
#### Service
246+
247+
```sh
248+
terraform state rm 'module.ecs_service.aws_security_group_rule.this["alb_ingress_3000"]'
249+
terraform state import 'module.ecs_service.aws_vpc_security_group_ingress_rule.this["alb_3000"]' 'sg-xxx'
250+
251+
terraform state rm 'module.ecs_service.aws_security_group_rule.this["egress_all"]'
252+
terraform state import 'module.ecs_service.aws_vpc_security_group_egress_rule.this["all"]' 'sg-xxx'
253+
254+
```
255+
256+
The inline tasks `aws_iam_role_policy` cannot be moved or imported into a standalone `aws_iam_policy`. It must be re-created.

examples/complete/main.tf

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module "ecs" {
8989
command = ["CMD-SHELL", "curl -f http://localhost:${local.container_port}/health || exit 1"]
9090
}
9191

92-
portPappings = [
92+
portMappings = [
9393
{
9494
name = local.container_name
9595
containerPort = local.container_port
@@ -101,12 +101,12 @@ module "ecs" {
101101
# Example image used requires access to write to root filesystem
102102
readonlyRootFilesystem = false
103103

104-
dependencies = [{
104+
dependsOn = [{
105105
containerName = "fluent-bit"
106106
condition = "START"
107107
}]
108108

109-
enableCloudwatchLogging = false
109+
enable_cloudwatch_logging = false
110110
logConfiguration = {
111111
logDriver = "awsfirelens"
112112
options = {
@@ -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: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,36 +117,37 @@ module "ecs_service" {
117117
container_definitions = {
118118
(local.container_name) = {
119119
image = "public.ecr.aws/ecs-sample-image/amazon-ecs-sample:latest"
120-
port_mappings = [
120+
portMappings = [
121121
{
122122
name = local.container_name
123123
containerPort = local.container_port
124+
hostPort = local.container_port
124125
protocol = "tcp"
125126
}
126127
]
127128

128-
mount_points = [
129+
mountPoints = [
129130
{
130131
sourceVolume = "my-vol",
131132
containerPath = "/var/www/my-vol"
132133
},
133134
{
134-
containerPath = "/ebs/data"
135135
sourceVolume = "ebs-volume"
136+
containerPath = "/ebs/data"
136137
}
137138
]
138139

139-
entry_point = ["/usr/sbin/apache2", "-D", "FOREGROUND"]
140+
entryPoint = ["/usr/sbin/apache2", "-D", "FOREGROUND"]
140141

141142
# Example image used requires access to write to root filesystem
142-
readonly_root_filesystem = false
143+
readonlyRootFilesystem = false
143144

144145
enable_cloudwatch_logging = true
145146
create_cloudwatch_log_group = true
146147
cloudwatch_log_group_name = "/aws/ecs/${local.name}/${local.container_name}"
147148
cloudwatch_log_group_retention_in_days = 7
148149

149-
log_configuration = {
150+
logLonfiguration = {
150151
logDriver = "awslogs"
151152
}
152153
}
@@ -162,11 +163,10 @@ module "ecs_service" {
162163

163164
subnet_ids = module.vpc.private_subnets
164165
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
166+
alb_http = {
167+
from_port = local.container_port
168+
description = "Service port"
169+
referenced_security_group_id = module.alb.security_group_id
170170
}
171171
}
172172

@@ -261,7 +261,7 @@ module "autoscaling" {
261261
ex_1 = {
262262
instance_type = "t3.large"
263263
use_mixed_instances_policy = false
264-
mixed_instances_policy = {}
264+
mixed_instances_policy = null
265265
user_data = <<-EOT
266266
#!/bin/bash
267267
@@ -284,16 +284,18 @@ module "autoscaling" {
284284
spot_allocation_strategy = "price-capacity-optimized"
285285
}
286286

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-
]
287+
launch_template = {
288+
override = [
289+
{
290+
instance_type = "m4.large"
291+
weighted_capacity = "2"
292+
},
293+
{
294+
instance_type = "t3.large"
295+
weighted_capacity = "1"
296+
},
297+
]
298+
}
297299
}
298300
user_data = <<-EOT
299301
#!/bin/bash

0 commit comments

Comments
 (0)