hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.72k stars 9.08k forks source link

[Bug]: aws_ecs_service fails when trying to set `idle_timeout_seconds` on `service_connect_configuration.service.timeout` #38432

Open corymhall opened 1 month ago

corymhall commented 1 month ago

Terraform Core Version

1.9.2

AWS Provider Version

5.48.0

Affected Resource(s)

aws_ecs_service

Expected Behavior

Expected to be able to successfully create the service.

Actual Behavior

apply fails with the below error.

Relevant Error/Panic Output Snippet

Error: creating ECS Service (broker): ClientException: Per request timeout 0 can't be set for tcp application.

Terraform Configuration Files

resource "aws_vpc" "example" {
  cidr_block = "10.0.0.0/16"
}

resource "aws_subnet" "example" {
  vpc_id            = aws_vpc.example.id
  cidr_block        = "10.0.160.0/20"
  availability_zone = "us-east-2b"
}
resource "aws_ecs_cluster" "example" {
  name = "my-cluster"
}
resource "aws_ecs_task_definition" "example" {
  family                   = "app"
  cpu                      = "256"
  memory                   = "512"
  network_mode             = "awsvpc"
  requires_compatibilities = ["FARGATE"]
  container_definitions = jsonencode([
    {
      name  = "app"
      image = "amazon/amazon-ecs-sample"
      portMappings = [
        {
          containerPort = 80
          hostPort      = 80
          // appProtocol = "http"
          name = "app"
        }
      ]
    }
  ])
}
resource "aws_security_group" "example" {
  vpc_id = aws_vpc.example.id
}

resource "aws_service_discovery_http_namespace" "example" {
  name = "my-service"
}
resource "aws_ecs_service" "example" {
  name            = "broker"
  cluster         = aws_ecs_cluster.example.arn
  task_definition = aws_ecs_task_definition.example.arn
  launch_type     = "FARGATE"
  desired_count   = 1
  network_configuration {
    assign_public_ip = false
    subnets          = [aws_subnet.example.id]
    security_groups  = [aws_security_group.example.id]
  }
  service_connect_configuration {
    enabled   = true
    namespace = aws_service_discovery_http_namespace.example.arn
    service {
      port_name      = "app"
      discovery_name = "broker"
      timeout {
        idle_timeout_seconds = 2147483647
        // perRequestTimeoutSeconds = // 0 - tried also setting this to 0 or undefined with no luck
      }
      client_alias {
        dns_name = "broker.platform.internal"
        port     = 6379
      }
    }
  }
}

Steps to Reproduce

Run terraform apply with the provided example.

Debug Output

No response

Panic Output

No response

Important Factoids

It looks like this may be due to assigning the Go default value 0 here https://github.com/hashicorp/terraform-provider-aws/blob/dcb29fd8dfa1b716aa7944b5de3ed363151b8142/internal/service/ecs/service.go#L1862-L1864

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 month ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue