-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(aws-ecs-patterns): Enable autoscaling with ApplicationLoadBalancedEc2Service #18868
Comments
Hey @5nafu, While you can't directly set this property on the L3 construct, you can use escape hatches to apply this property to the underlying service. const l3 = new ApplicationLoadBalancedFargateService(this, 'ALBFargateService', {
memoryLimitMiB: 1024,
taskImageOptions: {
image: ContainerImage.fromRegistry('test'),
environment: {
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value",
},
},
desiredCount: 2,
});
const l1 = l3.service.node.defaultChild as CfnService;
const cpsprops = {
base: 2,
weight: 2,
capacityProvider: 'capacityProvider'
}
l1.addPropertyOverride('CapacityProviderStrategy', cpsprops); |
Hi @peterwoodworth , thanks for the quick response. Unfortunately the above code results in a I needed to add So the complete code would be (adding as reference for future google searches): const l3 = new ApplicationLoadBalancedEc2Service(this, 'ALBFargateService', {
memoryLimitMiB: 1024,
taskImageOptions: {
image: ContainerImage.fromRegistry('test'),
environment: {
TEST_ENVIRONMENT_VARIABLE1: "test environment variable 1 value",
TEST_ENVIRONMENT_VARIABLE2: "test environment variable 2 value",
},
},
desiredCount: 2,
});
const l1 = l3.service.node.defaultChild as CfnService;
const cpsprops = [{
base: 2,
weight: 2,
capacityProvider: 'capacityProvider'
}];
l1.addPropertyOveride('CapacityProviderStrategy', cpsprops);
l1.addPropertyDeletionOverride('LaunchType'); That said, I would like to request the addition of the Cheers and thanks again for the hint with the escape hatches. |
Thanks for cleaning the code up, I only synthesized my code 🙂 I'll convert this to a feature request. Since this has a relatively easy workaround we don't have a timeline for it, but we happily accept community contributions. Check out our contributing guide if you're interested |
If I may, I would suggest that if you're running into issues like this, it's time to switch from L3 to L2 constructs. L3 are very opinionated and limit the available options by design, to make it easy for newcomers to spin up complex solutions. Once you're comfortable with it and are in need of deeper configuration, I'd go with L2 to have full control. |
@gshpychka thank you for the input, I tend to agree here, and directly implementing the prop just for the L2 construct wouldn't help with the abstraction the L3 is trying to offer. However, I believe there's a case for somehow abstracting the ability to autoscale the instances created 🙂 |
…ion/Network)LoadBalanced(Ec2/Fargate)Service (#20879) Add a property `capacityProviderStrategies` to the four constructs below. - ApplicationLoadBalancedEc2Service - NetworkLoadBalancedEc2Service - ApplicationLoadBalancedFargateService - NetworkLoadBalancedFargateService closes #18868 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…ion/Network)LoadBalanced(Ec2/Fargate)Service (aws#20879) Add a property `capacityProviderStrategies` to the four constructs below. - ApplicationLoadBalancedEc2Service - NetworkLoadBalancedEc2Service - ApplicationLoadBalancedFargateService - NetworkLoadBalancedFargateService closes aws#18868 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [x] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [x] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
General Issue
I would like to use an
ApplicationLoadBalancedEc2Service
together with autoscaling of EC2 instances.The Question
I would like to use an
ApplicationLoadBalancedEc2Service
together with an EC2 ASG. To enable autoscaling of the ECS instances, I would need to apply thecapacity_provider_strategies
parameter.The L2
@aws-cdk/aws-ecs.Ec2Service
already supports this option, but the L3 construct does not.Unfortunately the
EC2Service
does not allow to add this strategy later to the finished service either.CDK CLI Version
2.10.0
Framework Version
No response
Node.js Version
16.3.0
OS
OSX
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: