Skip to content

Commit 5e1c618

Browse files
authored
Add conditional container_port for service registry for A records (#42)
Fixes issue where no SRV record in service disvocery dns config causes the service_registries block in the aws_ecs_service resource to fail because it does not accept container_port parameter
1 parent 55c12b9 commit 5e1c618

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ resource "aws_ecs_service" "service" {
208208
for_each = var.service_registry_arn == "" ? [] : [1]
209209
content {
210210
registry_arn = var.service_registry_arn
211-
container_port = var.task_container_port
211+
container_port = var.with_service_discovery_srv_record ? var.task_container_port : null
212212
container_name = var.container_name != "" ? var.container_name : var.name_prefix
213213
}
214214
}

variables.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ variable "repository_credentials" {
144144
type = string
145145
}
146146

147-
148147
variable "repository_credentials_kms_key" {
149148
default = "alias/aws/secretsmanager"
150149
description = "key id, key ARN, alias name or alias ARN of the key that encrypted the repository credentials"
@@ -157,6 +156,12 @@ variable "service_registry_arn" {
157156
type = string
158157
}
159158

159+
variable "service_discovery_srv_record" {
160+
default = true
161+
type = bool
162+
description = "Set to false if you specify a SRV DNS record in aws_service_discovery_service. If only A record, set this to false."
163+
}
164+
160165
variable "stop_timeout" {
161166
description = "Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own. On Fargate the maximum value is 120 seconds."
162167
default = 30

0 commit comments

Comments
 (0)