After reading this resolved article, I decided to set up two AutoScalingGroup
, two AsgCapacityProvider
, and two ecs on ec2
service
Now, my goal is to attach these CapacityProvider
to each service
.
However, I encountered an error message stating:
The specified capacity provider myapp-dev-admin-cp was not found
const adminCapacityProvider = new ecs.AsgCapacityProvider(this, 'admin-asg-capacity-provider', {
autoScalingGroup:adminAutoScalingGroup,
capacityProviderName: `myapp-${targetEnv}-admin-cp`
});
const adminCapacityProvider2 = new ecs.AsgCapacityProvider(this, 'admin-asg-capacity-provider2', {
autoScalingGroup:adminAutoScalingGroup2,
capacityProviderName: `myapp-${targetEnv}-admin-cp2`
});
cluster.addAsgCapacityProvider(adminCapacityProvider);
cluster.addAsgCapacityProvider(adminCapacityProvider2);
const ecsAiService = new ecs.Ec2Service(this, 'AiService', {
cluster,
taskDefinition:aiTaskDefinition,
serviceName: `myapp-${targetEnv}-ai-service`,
enableExecuteCommand:true,
securityGroups: [adminServiceSg],
vpcSubnets:{subnetType: ec2.SubnetType.PUBLIC },
capacityProviderStrategies:[
capacityProvider:`myapp-${targetEnv}-admin-cp`// error occurs here
]
})
I researched further and discovered that for fargate, the options should be FARGATE
or FARGATE_SPOT
, but since mine is ECS on EC2
, I'm unsure what to use for capacityProviderStrategie's props.
If anyone can offer any assistance, it would be greatly appreciated. Thank you.