Skip to content

Commit 0d4ebc4

Browse files
committed
feat: add type definitions for variables
Move default values for optional variables from `main.tf` to `variables.tf`.
1 parent 06ef307 commit 0d4ebc4

File tree

2 files changed

+52
-5
lines changed

2 files changed

+52
-5
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ resource "aws_ecs_service" "this" {
4242
deployment_maximum_percent = try(var.service.deployment_maximum_percent, null)
4343
deployment_minimum_healthy_percent = try(var.service.deployment_minimum_healthy_percent, null)
4444
desired_count = try(var.service.desired_count, null)
45-
enable_ecs_managed_tags = try(var.service.enable_ecs_managed_tags, true)
45+
enable_ecs_managed_tags = try(var.service.enable_ecs_managed_tags, null)
4646
enable_execute_command = try(var.service.enable_execute_command, null)
4747
force_new_deployment = try(var.service.force_new_deployment, null)
4848
health_check_grace_period_seconds = try(var.service.health_check_grace_period_seconds, null)

variables.tf

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,28 @@ variable "vpc_id" {
1414

1515
variable "service" {
1616
description = "Configuration for ECS Service."
17-
type = any
17+
type = object({
18+
name = string
19+
deployment_maximum_percent = optional(number)
20+
deployment_minimum_healthy_percent = optional(number)
21+
desired_count = optional(number)
22+
enable_ecs_managed_tags = optional(bool, true)
23+
enable_execute_command = optional(bool)
24+
force_new_deployment = optional(bool, true)
25+
health_check_grace_period_seconds = optional(number)
26+
iam_role = optional(string)
27+
propagate_tags = optional(string)
28+
scheduling_strategy = optional(string)
29+
triggers = optional(map(string))
30+
wait_for_steady_state = optional(bool)
31+
load_balancer = optional(any)
32+
network_configuration = optional(any)
33+
service_connect_configuration = optional(any)
34+
volume_configuration = optional(any)
35+
deployment_circuit_breaker = optional(any)
36+
service_registries = optional(any)
37+
tags = optional(map(string), {})
38+
})
1839
}
1940

2041
################################################################################
@@ -23,7 +44,22 @@ variable "service" {
2344

2445
variable "task_definition" {
2546
description = "ECS Task Definition to use for running tasks."
26-
type = any
47+
type = object({
48+
container_definitions = any
49+
family = string
50+
cpu = optional(string)
51+
execution_role_arn = optional(string)
52+
ipc_mode = optional(string)
53+
memory = optional(string)
54+
network_mode = optional(string, "awsvpc")
55+
pid_mode = optional(string)
56+
skip_destroy = optional(bool)
57+
task_role_arn = optional(string)
58+
track_latest = optional(bool)
59+
runtime_platform = optional(any)
60+
volume = optional(any)
61+
tags = optional(map(string), {})
62+
})
2763
}
2864

2965
################################################################################
@@ -66,8 +102,19 @@ variable "create_alb" {
66102

67103
variable "load_balancer" {
68104
description = "Configuration for the Application Load Balancer."
69-
type = any
70-
default = {}
105+
type = object({
106+
name = optional(string)
107+
internal = optional(bool, false)
108+
subnets_ids = optional(list(string), [])
109+
security_groups_ids = optional(list(string), [])
110+
preserve_host_header = optional(bool)
111+
enable_deletion_protection = optional(bool, false)
112+
target_groups = optional(any, {})
113+
listeners = optional(any, {})
114+
listener_rules = optional(any, {})
115+
tags = optional(map(string), {})
116+
})
117+
default = {}
71118
}
72119

73120
################################################################################

0 commit comments

Comments
 (0)