0
votes

Hi I am creating AWS CDK stack for ECS. I have created service, cluster, task definition and load balancer. Now I see LaunchConfiguration and Auto scaling also created automatically. But I want to override this launch configuration.

Also I have one method

  cluster.add_capacity("MWSServiceAutoScaling",
            instance_type=ec2.InstanceType("t2.micro"),
            key_name="mws-location",
            desired_capacity=1,
        )

I copied this from google. I am not sure what it does? If I remove this I get error Cluster for this service needs Ec2 capacity. Call addXxxCapacity() on the cluster.

Can someone tell me how to have my own launch configuration and auto scaling? Any help would be appreciated. Thanks

1

1 Answers

1
votes

CDK API clearly explains what it does.

https://docs.aws.amazon.com/cdk/api/latest/python/aws_cdk.aws_ecs/Cluster.html

This method adds compute capacity to a cluster by creating an AutoScalingGroup with the specified options. Returns the AutoScalingGroup so you can add autoscaling settings to it.

You can further customise your ASG and LC through the object returned by this function.