Skip to content

(ecs-patterns): omiting cluster and specifying only vpc results in an error  #18519

@madeline-k

Description

@madeline-k

What is the problem?

The ecs-patterns README states that 'Instead of providing a cluster you can specify a VPC and CDK will create a new ECS cluster.' However, omiting the cluster prop and only provided a vpc results in an error. And there is not clear direction on how to do this properly.

So far I have noticed this issue with the following constructs. It might apply to more.

  • NetworkMultipleTargetGroupsEc2Service
  • ApplicationMultipleTargetGroupsEc2Service
  • ApplicationLoadBalancedEc2Service

This might just be a miss in the documentation, and not missing functionality. I will need to dive deeper into this to find out.

Reproduction Steps

Synthesize and app with this sample code:

    const stack = new Stack();
    const vpc = new Vpc(stack, 'VPC');

    const service = new ApplicationMultipleTargetGroupsEc2Service(stack, 'Service', {
      vpc,
      memoryLimitMiB: 1024,
      taskImageOptions: {
        image: ContainerImage.fromRegistry('test'),
      },
    });

What did you expect to happen?

No errors, and it synthesizes an ECS service with a cluster created by the CDK.

What actually happened?

I get this error:

      [Default/Service/Service] Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.

CDK CLI Version

1.139.0

Framework Version

No response

Node.js Version

12.22.7

OS

MacOS

Language

Typescript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-ecs-patternsRelated to ecs-patterns librarybugThis issue is a bug.effort/mediumMedium work item – several days of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions