Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECS container service_registries don't work as expected #331

Closed
PhungV0 opened this issue Nov 8, 2022 · 2 comments
Closed

ECS container service_registries don't work as expected #331

PhungV0 opened this issue Nov 8, 2022 · 2 comments
Assignees

Comments

@PhungV0
Copy link

PhungV0 commented Nov 8, 2022

Describe the bug
ECS container service_registries doesn't work as expected.
The container_port and port for service_registries should be optional, but in the module it required the input.
I need to disable both container_port and port value from trussworks/ecs-service module main.tf and variables.tf to run terraform apply correctly.

Using
AWS CLI aws-cli/2.2.38
terraform v1.3.4
module "ecs-service" {
source = "trussworks/ecs-service/aws"
version ="6.6.0"

main.tf
dynamic "service_registries" {
for_each = var.service_registries
content {
registry_arn = service_registries.value.registry_arn
container_name = service_registries.value.container_name
#container_port = service_registries.value.container_port
#port = service_registries.value.port
}
}

variable "service_registries" {
description = ""
type = list(object({
registry_arn = string
container_name = string
#container_port = number
#port = number
}))
default = []
}

@jsclarridge
Copy link

@PhungV0 Apologies for the delayed response. I can work on a PR to try and fix this. I think Optional Object Type Attributes may be what we need here.

variable "with_optional_attribute" {
  type = object({
    a = string                # a required attribute
    b = optional(string)      # an optional attribute
    c = optional(number, 127) # an optional attribute with default value
  })
}

@jsclarridge
Copy link

@PhungV0 Setting container_port and port to null appears to work without modifying the the module's main.tf and variables.tf files:

service_registries = [
    {
      registry_arn   = aws_service_discovery_service.main.arn,
      container_name = "app"
      container_port = null
      port           = null
    }
]

Designating some of that input variable's attributes as optional would also work (see #341), but we would likely want to update the module's terraform version constraint to be >= 1.3.

I'm going to close this issue for now as there appears to be a workaround in place, but please re-open this issue if the above approach does not meet your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants