cloudposse / terraform-aws-ecs-container-definition

Terraform module to generate well-formed JSON documents (container definitions) that are passed to the aws_ecs_task_definition Terraform resource
https://cloudposse.com/accelerate
Apache License 2.0
340 stars 245 forks source link

Log Configuration Options should be options #151

Closed fszymanski-blvd closed 1 year ago

fszymanski-blvd commented 2 years ago

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

According to the log configuration documentation, the options section is not required. Our use case for this is a docker container with log configuration embedded in the dockerfile to allow for multiple outputs when using ECS Fargate.

If you try to create a container definition with the following setup

log_configuration = {
  logDriver = "json-file"
}

You will get the following error:

Error: Invalid function argument

  on .terraform/modules/fargate.container_definition/main.tf line 45, in locals:
  45:     options   = tomap(lookup(var.log_configuration, "options"))
    |----------------
    | var.log_configuration is object with 1 attribute "logDriver"

Invalid value for "inputMap" parameter: the given object has no attribute
"options"

Expected Behavior

The container definition should be created with empty options.

nitrocode commented 2 years ago

Unfortunately every key needs to be defined

See this in our examples

https://github.com/cloudposse/terraform-aws-ecs-container-definition/blob/ec4c4a662fe3f5d9d8cf594a41d31e10e13bd8f9/examples/complete/fixtures.us-east-2.tfvars#L49-L56

For every key that is unneeded, try using null

obataku commented 2 years ago

https://github.com/cloudposse/terraform-aws-ecs-container-definition/pull/154 should resolve