Skip to content

Commit e987f75

Browse files
committed
feat: The worlds longest variable definition
1 parent 0277e00 commit e987f75

File tree

10 files changed

+933
-189
lines changed

10 files changed

+933
-189
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs/UPGRADE-6.0.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Upgrade from v5.x to v6.x
2+
3+
If you have any questions regarding this upgrade process, please consult the [`examples`](https://github.com/terraform-aws-modules/terraform-aws-ecs/tree/master/examples) directory:
4+
If you find a bug, please open an issue with supporting configuration to reproduce.
5+
6+
## List of backwards incompatible changes
7+
8+
- Terraform v1.5.7 is now minimum supported version
9+
- AWS provider v6.0.0 is now minimum supported version
10+
11+
## Additional changes
12+
13+
### Added
14+
15+
- Support for `region` parameter to specify the AWS region for the resources created if different from the provider region.
16+
17+
### Modified
18+
19+
- Variable definitions now contain detailed `object` types in place of the previously used any type.
20+
21+
### Variable and output changes
22+
23+
1. Removed variables:
24+
25+
-
26+
27+
2. Renamed variables:
28+
29+
-
30+
31+
3. Added variables:
32+
33+
-
34+
35+
4. Removed outputs:
36+
37+
-
38+
39+
5. Renamed outputs:
40+
41+
-
42+
43+
6. Added outputs:
44+
45+
-
46+
47+
## Upgrade Migrations
48+
49+
### Before 5.x Example
50+
51+
```hcl
52+
module "ecs" {
53+
source = "terraform-aws-modules/ecs/aws"
54+
version = "~> 5.0"
55+
56+
# Truncated for brevity ...
57+
58+
}
59+
```
60+
61+
### After 6.x Example
62+
63+
```hcl
64+
module "ecs" {
65+
source = "terraform-aws-modules/ecs/aws"
66+
version = "~> 6.0"
67+
68+
# Truncated for brevity ...
69+
70+
}
71+
```
72+
73+
### State Changes
74+
75+
TODO

examples/complete/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ module "ecs" {
7373
memory = 1024
7474
essential = true
7575
image = nonsensitive(data.aws_ssm_parameter.fluentbit.value)
76-
firelens_configuration = {
76+
firelensConfiguration = {
7777
type = "fluentbit"
7878
}
79-
memory_reservation = 50
79+
memoryReservation = 50
8080
}
8181

8282
(local.container_name) = {
@@ -85,11 +85,11 @@ module "ecs" {
8585
essential = true
8686
image = "public.ecr.aws/aws-containers/ecsdemo-frontend:776fd50"
8787

88-
health_check = {
88+
healthCheck = {
8989
command = ["CMD-SHELL", "curl -f http://localhost:${local.container_port}/health || exit 1"]
9090
}
9191

92-
port_mappings = [
92+
portPappings = [
9393
{
9494
name = local.container_name
9595
containerPort = local.container_port
@@ -99,15 +99,15 @@ module "ecs" {
9999
]
100100

101101
# Example image used requires access to write to root filesystem
102-
readonly_root_filesystem = false
102+
readonlyRootFilesystem = false
103103

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

109-
enable_cloudwatch_logging = false
110-
log_configuration = {
109+
enableCloudwatchLogging = false
110+
logConfiguration = {
111111
logDriver = "awsfirelens"
112112
options = {
113113
Name = "firehose"
@@ -116,9 +116,9 @@ module "ecs" {
116116
log-driver-buffer-limit = "2097152"
117117
}
118118
}
119-
memory_reservation = 100
119+
memoryReservation = 100
120120

121-
restart_policy = {
121+
restartPolicy = {
122122
enabled = true
123123
ignoredExitCodes = [1]
124124
restartAttemptPeriod = 60

main.tf

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

modules/service/README.md

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

modules/service/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ data "aws_iam_policy_document" "tasks" {
11531153
}
11541154

11551155
dynamic "condition" {
1156-
for_each = statement.value.conditions != null ? statement.value.conditions : []
1156+
for_each = statement.value.condition != null ? statement.value.condition : []
11571157

11581158
content {
11591159
test = condition.value.test
@@ -1177,7 +1177,7 @@ resource "aws_iam_policy" "tasks" {
11771177
}
11781178

11791179
resource "aws_iam_role_policy_attachment" "tasks" {
1180-
count = local.create_tasks_iam_role && (length(var.tasks_iam_role_statements) > 0 || var.enable_execute_command) ? 1 : 0
1180+
count = local.create_tasks_iam_role && (var.tasks_iam_role_statements != null || var.enable_execute_command) ? 1 : 0
11811181

11821182
role = aws_iam_role.tasks[0].name
11831183
policy_arn = aws_iam_policy.tasks[0].arn

modules/service/variables.tf

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,6 @@ variable "triggers" {
270270
default = null
271271
}
272272

273-
variable "wait_for_steady_state" {
274-
description = "If true, Terraform will wait for the service to reach a steady state before continuing. Default is `false`"
275-
type = bool
276-
default = null
277-
}
278-
279273
variable "volume_configuration" {
280274
description = "Configuration for a volume specified in the task definition as a volume that is configured at launch time"
281275
type = object({
@@ -309,6 +303,12 @@ variable "vpc_lattice_configurations" {
309303
default = null
310304
}
311305

306+
variable "wait_for_steady_state" {
307+
description = "If true, Terraform will wait for the service to reach a steady state before continuing. Default is `false`"
308+
type = bool
309+
default = null
310+
}
311+
312312
variable "service_tags" {
313313
description = "A map of additional tags to add to the service"
314314
type = map(string)
@@ -412,7 +412,6 @@ variable "task_definition_arn" {
412412
variable "container_definitions" {
413413
description = "A map of valid [container definitions](http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html). Please note that you should only provide values that are part of the container definition document"
414414
type = map(object({
415-
region = optional(string)
416415
enable_execute_command = optional(bool, false)
417416
operating_system_family = optional(string, "LINUX")
418417
tags = optional(map(string), {})
@@ -556,7 +555,6 @@ variable "container_definitions" {
556555
variable "container_definition_defaults" {
557556
description = "A map of default values for [container definitions](http://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_ContainerDefinition.html) created by `container_definitions`"
558557
type = map(object({
559-
region = optional(string)
560558
enable_execute_command = optional(bool, false)
561559
operating_system_family = optional(string, "LINUX")
562560
tags = optional(map(string), {})
@@ -747,15 +745,6 @@ variable "pid_mode" {
747745
default = null
748746
}
749747

750-
variable "task_definition_placement_constraints" {
751-
description = "Configuration block for rules that are taken into consideration during task placement (up to max of 10). This is set at the task definition, see `placement_constraints` for setting at the service"
752-
type = map(object({
753-
expression = optional(string)
754-
type = string
755-
}))
756-
default = null
757-
}
758-
759748
variable "proxy_configuration" {
760749
description = "Configuration block for the App Mesh proxy"
761750
type = object({
@@ -790,6 +779,15 @@ variable "skip_destroy" {
790779
default = null
791780
}
792781

782+
variable "task_definition_placement_constraints" {
783+
description = "Configuration block for rules that are taken into consideration during task placement (up to max of 10). This is set at the task definition, see `placement_constraints` for setting at the service"
784+
type = map(object({
785+
expression = optional(string)
786+
type = string
787+
}))
788+
default = null
789+
}
790+
793791
variable "track_latest" {
794792
description = "Whether should track latest `ACTIVE` task definition on AWS or the one created with the resource stored in state. Default is `false`. Useful in the event the task definition is modified outside of this resource"
795793
type = bool
@@ -911,13 +909,13 @@ variable "create_task_exec_policy" {
911909
variable "task_exec_ssm_param_arns" {
912910
description = "List of SSM parameter ARNs the task execution role will be permitted to get/read"
913911
type = list(string)
914-
default = ["arn:aws:ssm:*:*:parameter/*"]
912+
default = []
915913
}
916914

917915
variable "task_exec_secret_arns" {
918916
description = "List of SecretsManager secret ARNs the task execution role will be permitted to get/read"
919917
type = list(string)
920-
default = ["arn:aws:secretsmanager:*:*:secret:*"]
918+
default = []
921919
}
922920

923921
variable "task_exec_iam_statements" {
@@ -1145,9 +1143,6 @@ variable "autoscaling_policies" {
11451143
scale_out_cooldown = optional(number, 60)
11461144
target_value = optional(number, 75)
11471145
}))
1148-
1149-
1150-
11511146
default = {
11521147
cpu = {
11531148
policy_type = "TargetTrackingScaling"
@@ -1225,7 +1220,7 @@ variable "security_group_ingress_rules" {
12251220
tags = optional(map(string), {})
12261221
to_port = optional(string)
12271222
}))
1228-
default = null
1223+
default = {}
12291224
}
12301225

12311226
variable "security_group_egress_rules" {
@@ -1241,7 +1236,7 @@ variable "security_group_egress_rules" {
12411236
tags = optional(map(string), {})
12421237
to_port = optional(string)
12431238
}))
1244-
default = null
1239+
default = {}
12451240
}
12461241

12471242
variable "security_group_tags" {
@@ -1251,7 +1246,7 @@ variable "security_group_tags" {
12511246
}
12521247

12531248
############################################################################################
1254-
# ECS infrastructure IAM role
1249+
# ECS Infrastructure IAM role
12551250
############################################################################################
12561251

12571252
variable "create_infrastructure_iam_role" {

0 commit comments

Comments
 (0)