lively-van-23101
04/20/2024, 9:30 PMbland-painting-33593
04/21/2024, 4:04 AMquick-house-41860
04/23/2024, 3:45 PM// Define an Auto Scaling Group (ASG) that will provide the capacity for our ECS tasks
const asg = new aws.autoscaling.Group("asg", {
// ... other configuration like VPC subnets, security group, launch configuration/template
maxSize: 5,
minSize: 1,
});
// Create an ECS capacity provider that is tied to the ASG defined above
const capacityProvider = new aws.ecs.CapacityProvider("my-capacity-provider", {
autoScalingGroupProvider: {
autoScalingGroupArn: asg.arn,
managedScaling: {
status: "ENABLED",
targetCapacity: 75, // The target utilization for the capacity provider
},
},
});
// Associate the capacity provider with your ECS cluster
const clusterCapacityProviders = new aws.ecs.ClusterCapacityProviders("my-cluster-cap-providers", {
clusterName: cluster.name,
capacityProviders: [capacityProvider.name],
defaultCapacityProviderStrategies: [
{
capacityProvider: capacityProvider.name,
weight: 1,
base: 1,
},
],
});
In the service resource you also need to set launchType: "EC2"
and reference the capacity provider like so:
capacityProviderStrategies: [
{
capacityProvider: capacityProvider.name,
weight: 1,
base: 1,
},
]
lively-van-23101
05/04/2024, 6:35 PMClusterCapacityProviders
piece. This is a side project, so I can't put the time I would like into it (thus the delay in testing out your suggestion). My cluster now finds the ec2 backed asg and gets stuck in pending (before it said it couldn't find anywhere to deploy, so progress 🙂). It seems that the "stuck on pending" issue is related to networking, so I just need to do some more research/digging there.
Interestingly, if I ssh to the ec2 instance that is in the asg, I can execute docker run -p 80:80 httpd
and then hit the public IP from my browser. So, some of the networking pieces are there, but there is probably a link in the chain I have overlooked.
I was completely out of ideas, and the ClusterCapacityProviders
piece has gotten me un-stuck. I really appreciate your help!