Skip to content

aws-ecs: Resource handler returned message: "Invalid request provided: The target group with targetGroupArn <redacted> does not have an associated load balancer." #34290

Open
@BwL1289

Description

@BwL1289

Describe the bug

With this workaround for redirecting HTTP to HTTPS on an ALB, I indeterminately experience the following:

CoreStackDev | 28/70 | 5:02:27 PM | UPDATE_FAILED        | AWS::ECS::Service                             | WebAppSvc/FlaskAppService/ControlPlane/ApplicationLoadBalancerFargateSvc/AlbFargateSvc/Service/Service (WebAppSvcFlaskAppServiceControlPlaneApplicationLoadBalancerFargateSvcAlbFargateSvcServiceADE54F9D) Resource handler returned message: "Invalid request provided: The target group with targetGroupArn <redacted> does not have an associated load balancer. (Service: Ecs, Status Code: 400, Request ID: 91fd6146-d2f3-4534-bbdb-893469be2a1d) (SDK Attempt Count: 1)" (RequestToken: 25bc3e51-6110-4b81-8256-f4c02c60a863, HandlerErrorCode: InvalidRequest)

I tested redeploying multiple times (and changing the ECS Service, ALB, Task definition logicalids to recreate the resources) to no avail.

It looks like there's either:

  1. A race condition (regression)? somewhere. What's strange is this was working fine for a few days with multiple successful redeployments in between the original deployment and experiencing the error.
  2. Some other reason why cloudformation thinks an old ALB target group exists when it does not

After removing the listener redirection (lb.ListenerAction.redirect) the deployment succeeded again.

My ticket is related.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

Successful deployment

Current Behavior

Indeterminate Invalid request provided: The target group with targetGroupArn <arn> does not have an associated load balancer.

Reproduction Steps

  1. Deploy an ALB with ecs_patterns.ApplicationLoadBalancedFargateService with protocol=lb.ApplicationProtocol.HTTP,
  2. Use this workaround to redirect HTTP to HTTPSand deploy
  3. Deploy a few times...
  4. Maybe experience error?

Possible Solution

No response

Additional Information/Context

"userAgent": "cloudformation.amazonaws.com",
    "errorCode": "InvalidParameterException",
    "errorMessage": "The target group with <redacted>/CoreSt-WebAp-OBAY5UVSDTFW/5f79f6f39969fa92 does not have an associated load balancer.",
    "requestParameters": {
        "capacityProviderStrategy": [
            {
                "capacityProvider": "FARGATE",
                "weight": 1,
                "base": 1
            }
        ],
        "cluster": "CoreStackDev-WebAppSvcFlaskAppServiceControlPlaneEcsClusterSvcEcsClusterEcsClusterSvcB291F355-xtUAqFpdBbkj",
        "deploymentConfiguration": {
            "deploymentCircuitBreaker": {
                "enable": true,
                "rollback": true
            },
            "maximumPercent": 200,
            "minimumHealthyPercent": 100,
            "alarms": {
                "rollback": false,
                "enable": false
            }
        },
        "desiredCount": 1,
        "enableECSManagedTags": true,
        "enableExecuteCommand": true,
        "availabilityZoneRebalancing": "DISABLED",
        "forceNewDeployment": false,
        "healthCheckGracePeriodSeconds": 60,
        "loadBalancers": [
            {
                "targetGroupArn": "<redacted>/CoreSt-WebAp-OBAY5UVSDTFW/5f79f6f39969fa92",
                "containerName": "EcsTaskDefContainerSvcEcsContainerDef",
                "containerPort": 80
            },
            {
                "targetGroupArn": "<redacted>/CoreSt-WebAp-XB77YZBVGDH8/559a5660e756f528",
                "containerName": "EcsTaskDefContainerSvcEcsContainerDef",
                "containerPort": 80
            }
        ],

CDK CLI Version

2.180.0

Framework Version

No response

Node.js Version

v22.12.0

OS

Mac

Language

Python

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecsRelated to Amazon Elastic ContainerbugThis issue is a bug.p1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions