|
| 1 | +####################### |
| 2 | +# ECS Cluster Variables |
| 3 | +####################### |
| 4 | + |
| 5 | +variable "create_cluster" { |
| 6 | + description = "Creates an ECS cluster" |
| 7 | + type = bool |
| 8 | + default = true |
| 9 | +} |
| 10 | + |
| 11 | +variable "cluster_name" { |
| 12 | + description = "Name of the ECS Cluster to create" |
| 13 | + type = string |
| 14 | + default = "" |
| 15 | +} |
| 16 | + |
| 17 | +variable "cluster_tags" { |
| 18 | + description = "Resource Tags for ECS Cluster" |
| 19 | + type = map(any) |
| 20 | + default = {} |
| 21 | +} |
| 22 | + |
| 23 | +####################### |
| 24 | +# ECS Service Variables |
| 25 | +####################### |
| 26 | + |
| 27 | +variable "service_name" { |
| 28 | + description = "Name of the ECS Service" |
| 29 | + type = string |
| 30 | +} |
| 31 | + |
| 32 | +variable "cluster_arn" { |
| 33 | + description = "ARN of the ECS cluster under which the service will be created" |
| 34 | + type = string |
| 35 | + default = null |
| 36 | + |
| 37 | + validation { |
| 38 | + condition = var.create_cluster == true || startswith(var.cluster_arn != null ? var.cluster_arn : "", "arn:") |
| 39 | + error_message = "Specified Cluster ARN must be a valid ARN starting with \"arn:\"." |
| 40 | + } |
| 41 | +} |
| 42 | + |
| 43 | +variable "service_subnet_ids" { |
| 44 | + description = "VPC subnet ids where the ECS services will be deployed" |
| 45 | + type = list(string) |
| 46 | + |
| 47 | + validation { |
| 48 | + condition = length(var.service_subnet_ids) > 0 |
| 49 | + error_message = "Specified subnet ids must contain at least one valid subnet identifier." |
| 50 | + } |
| 51 | + |
| 52 | + validation { |
| 53 | + condition = alltrue([for subnet_id in var.service_subnet_ids : startswith(subnet_id, "subnet-")]) |
| 54 | + error_message = "Specified subnet ids must be valid subnet identifiers starting with \"subnet-\"." |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | +variable "service_cpu" { |
| 59 | + description = "CPU allocation for ECS task definitions" |
| 60 | + type = number |
| 61 | + |
| 62 | + validation { |
| 63 | + condition = var.service_cpu > 0 |
| 64 | + error_message = "Specified CPU allocation must be a positive number." |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +variable "service_memory" { |
| 69 | + description = "Memory allocation for ECS task definitions" |
| 70 | + type = number |
| 71 | + |
| 72 | + validation { |
| 73 | + condition = var.service_memory > 0 |
| 74 | + error_message = "Specified Memory allocation must be a positive number." |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +variable "service_tags" { |
| 79 | + description = "Resource Tags for ECS Service" |
| 80 | + type = map(any) |
| 81 | + default = {} |
| 82 | +} |
0 commit comments