Skip to content

Service module forces you to specify a log driver or enable cloudwatch in v6 #318

@livingforjesus

Description

@livingforjesus

Description

If I provide the container definition for a fluent bit sidecar and I set enable_cloudwatch_logging and create_cloudwatch_log_group to false, aws throws an error saying logDriver is required. This only started happening in v6. This is because of this diff in logConfiguration I believe(no longer defaulting to null whenever there is no logConfiguration).

Image
  • [x ] ✋ I have searched the open/closed issues and my issue is not listed.

Versions

  • Module version [Required]:

  • Terraform version: v6

  • Provider version(s): v6

Reproduction Code

module "ecs" {
  source = "terraform-aws-modules/ecs/aws"
  ...others
  services = {
    ecsdemo-frontend = {
     ...others
      container_definitions = {
        fluent-bit = {
          cpu       = 512
          memory    = 1024
          essential = true
          image     = "906394416424.dkr.ecr.us-west-2.amazonaws.com/aws-for-fluent-bit:stable"
          firelensConfiguration = {
            type = "fluentbit"
          }
          create_cloudwatch_log_group = false
          memoryReservation = 50
        }

       ...others
     }
}

Steps to reproduce the behavior:

  1. Ensure create_cloudwatch_log_group is set to false and no logConfiguration is defined
  2. Run the terraform code
  3. It throws an error in aws

Expected behavior

It didnt throw an error before v6 so I dont expect it to throw either. I expect logConfiguration to just be defaulted(in aws) to whatever it usually was.

Actual behavior

It threw an error

 Error: creating ECS Task Definition (app1-staging-api): operation error ECS: RegisterTaskDefinition, 1 validation error(s) found.
    │ - missing required field, RegisterTaskDefinitionInput.ContainerDefinitions[1].LogConfiguration.LogDriver.
    │ 
    │ 
    │   with module.ecs_service["app1-staging-api"].aws_ecs_task_definition.this[0],
    │   on .terraform/modules/ecs_service/modules/service/main.tf line 769, in resource "aws_ecs_task_definition" "this":
    │  769: resource "aws_ecs_task_definition" "this" {
    │ 
    ╵
    ╷
    │ Error: creating ECS Task Definition (app2-staging-api): operation error ECS: RegisterTaskDefinition, 1 validation error(s) found.
    │ - missing required field, RegisterTaskDefinitionInput.ContainerDefinitions[1].LogConfiguration.LogDriver.
    │ 
    │ 
    │   with module.ecs_service["app2-staging-api"].aws_ecs_task_definition.this[0],
    │   on .terraform/modules/ecs_service/modules/service/main.tf line 769, in resource "aws_ecs_task_definition" "this":
    │  769: resource "aws_ecs_task_definition" "this" {
    │ 
    ╵

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions