Skip to content

Commit

Permalink
Add conditional container_port for service registry for A records (#42)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
larstobi authored Jan 4, 2021
1 parent 55c12b9 commit 5e1c618
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ resource "aws_ecs_service" "service" {
for_each = var.service_registry_arn == "" ? [] : [1]
content {
registry_arn = var.service_registry_arn
container_port = var.task_container_port
container_port = var.with_service_discovery_srv_record ? var.task_container_port : null
container_name = var.container_name != "" ? var.container_name : var.name_prefix
}
}
Expand Down
7 changes: 6 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ variable "repository_credentials" {
type = string
}


variable "repository_credentials_kms_key" {
default = "alias/aws/secretsmanager"
description = "key id, key ARN, alias name or alias ARN of the key that encrypted the repository credentials"
Expand All @@ -157,6 +156,12 @@ variable "service_registry_arn" {
type = string
}

variable "service_discovery_srv_record" {
default = true
type = bool
description = "Set to false if you specify a SRV DNS record in aws_service_discovery_service. If only A record, set this to false."
}

variable "stop_timeout" {
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."
default = 30
Expand Down

0 comments on commit 5e1c618

Please sign in to comment.