Skip to content
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: support capacity provider #5471

Closed
1 of 2 tasks
pahud opened this issue Dec 18, 2019 · 20 comments · Fixed by #14386
Closed
1 of 2 tasks

aws-ecs: support capacity provider #5471

pahud opened this issue Dec 18, 2019 · 20 comments · Fixed by #14386
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1

Comments

@pahud
Copy link
Contributor

pahud commented Dec 18, 2019

https://aws.amazon.com/tw/about-aws/whats-new/2019/12/amazon-ecs-capacity-providers-now-available/

Use Case

Proposed Solution

Other

dependency aws/containers-roadmap#631

  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@pahud pahud added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2019
@SoManyHs SoManyHs added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. @aws-cdk/aws-ecs Related to Amazon Elastic Container and removed needs-triage This issue or PR still needs to be triaged. labels Dec 18, 2019
@ali-habibzadeh
Copy link

What is the likelihood of this being added to cfn?

@mb-dev
Copy link

mb-dev commented Jul 1, 2020

Capacity Providers were just added to Cfn: 4ce27f4#diff-4a4e15a081904ee16b4d84e2f5cf5aee

@mb-dev
Copy link

mb-dev commented Jul 1, 2020

FYI: @SoManyHs

@instigardo
Copy link

instigardo commented Jul 2, 2020

 const ondemandCapacity = cluster.addCapacity("OnDemandCapacity",{
          instanceType: new InstanceType(instanceType),
          minCapacity: 1,
          maxCapacity: 2,
          vpcSubnets: {
            subnets: vpc.privateSubnets
          }
        })
        const ondemandCapacityProvider = new CfnCapacityProvider(this, "OnDemandCapacityProvider", {
          name: "ondemandCapacityProvider",
          autoScalingGroupProvider: {
            autoScalingGroupArn: ondemandCapacity.autoScalingGroupArn,
            managedScaling: {
              maximumScalingStepSize: 10,
              minimumScalingStepSize: 1,
              status: "ENABLED",
              targetCapacity: 85
            }
          }
        })

This keeps on giving error
Invalid request provided: CreateCapacityProvider error: The specified Auto Scaling group ARN is invalid. Specify a valid ARN and try again.

@mb-dev
Copy link

mb-dev commented Jul 2, 2020

See here about some issues with the current implementation:
aws/containers-roadmap#631

These are items that still planned to be implemented:

Ability to reference the ASG name in the AWS::ECS::CapacityProvider resource
Ability to specify a custom capacity provider strategy in the AWS::ECS::Service resource
Ability to enable scale-in protection in the AWS::AutoScaling::AutoScalingGroup resource

@gandroz
Copy link

gandroz commented Jul 20, 2020

 const ondemandCapacity = cluster.addCapacity("OnDemandCapacity",{
          instanceType: new InstanceType(instanceType),
          minCapacity: 1,
          maxCapacity: 2,
          vpcSubnets: {
            subnets: vpc.privateSubnets
          }
        })
        const ondemandCapacityProvider = new CfnCapacityProvider(this, "OnDemandCapacityProvider", {
          name: "ondemandCapacityProvider",
          autoScalingGroupProvider: {
            autoScalingGroupArn: ondemandCapacity.autoScalingGroupArn,
            managedScaling: {
              maximumScalingStepSize: 10,
              minimumScalingStepSize: 1,
              status: "ENABLED",
              targetCapacity: 85
            }
          }
        })

This keeps on giving error
Invalid request provided: CreateCapacityProvider error: The specified Auto Scaling group ARN is invalid. Specify a valid ARN and try again.

got the same issue in v1.53 :(

@mb-dev
Copy link

mb-dev commented Jul 20, 2020

@gandroz did you try putting asg name in the autoScalingGroupArn field? they added this option recently.

@gandroz
Copy link

gandroz commented Jul 20, 2020

@gandroz did you try putting asg name in the autoScalingGroupArn field? they added this option recently.

hmmm good catch @mb-dev, using asg.autoScalingGroupName as the autoScalinGroupArn option does not raise an error, however I can see the capacity provider in the CloudFormation template but not in the ECS console....

How to link the capacity provider to the cluster ?

@pahud
Copy link
Contributor Author

pahud commented Jul 21, 2020

Hi folks,

I am working on the PR today and seems working fine in my integ test.

See: https://twitter.com/pahudnet/status/1285440342045515777

Will create a PR draft shortly.

@SomayaB SomayaB added the in-progress This issue is being actively worked on. label Jul 21, 2020
@iamhopaul123
Copy link
Contributor

We'll hold this issue because there are some feature gaps for CFN Capacity Provider to be narrowed. For example, the cyclic dependency that is already discussed here. Even if we try to break the cyclic dependency by using the hard code cluster name, we'll still have problems when deleting resources. Hence, we decided to hold this issue and wait for CFN update on Capacity Provider before we support it in CDK.

@SomayaB SomayaB added the blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. label Oct 21, 2020
@SomayaB SomayaB assigned MrArnoldPalmer and unassigned SoManyHs and piradeepk Oct 21, 2020
@andreialecu
Copy link
Contributor

@iamhopaul123 I believe this may have been unblocked recently?

https://aws.amazon.com/about-aws/whats-new/2020/10/aws-fargate-spot-for-amazon-ecs-now-supported-in-aws-cloudformation/

I'm not sure if it only applies to Fargate and whether it can work with EC2 as well.

@iamhopaul123
Copy link
Contributor

iamhopaul123 commented Nov 3, 2020

Hi @andreialecu thank you so much for bringing this great news to us! We'll take a look at it to see if it could fit in fixing this issue.

@iamhopaul123
Copy link
Contributor

Hello @andreialecu, looks like number 4 and 5 of aws/containers-roadmap#631 (comment) are still waiting to be fixed. Unfortunately though CFN support could simplify the CDK support for quite a lot, without fixing the circular dependency problem there is not much we could do. We'll keep waiting until there are more updates on this.

@pv93
Copy link

pv93 commented Jan 25, 2021

Hello everyone. Is there any news on this issue?

@muraleee
Copy link

Is this coming soon?

@iamhopaul123
Copy link
Contributor

Hello, we don't have any update for now. We'll update this issue we there's any news.

@SoManyHs SoManyHs added blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. and removed blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. labels Mar 16, 2021
@rsmogura
Copy link
Contributor

rsmogura commented Apr 3, 2021

We are interest in this too, mainly due possibilities to use launch templates.

I think I’ve got idea how to solve it and I did preliminary tests.

We could create custom cloud formation resource “CapacityProviderAttachment”, which will have two inputs cluster & capacity providers - this is simple lambda. Custom resource could be part of “bootstrap” or some kind of inner stack (I prefer later as CF templates are commonly used).

The resource would call put-capacity-providers on creation and remove from cluster on deletion.

I would have to validate deletion only, to have final results.

@otterley
Copy link
Contributor

otterley commented Apr 6, 2021

Supporting EC2 Capacity Providers may now be possible, now that the AWS::ECS::ClusterCapacityProviderAssociations resource is available.

@rsmogura
Copy link
Contributor

rsmogura commented Apr 6, 2021

I missed this one. So this ticket and bunch of other leading to launch templates can be shortly solved.``

@SoManyHs SoManyHs removed blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. labels May 5, 2021
@mergify mergify bot closed this as completed in #14386 May 12, 2021
mergify bot pushed a commit that referenced this issue May 12, 2021
Add support for EC2 Capacity Providers.

I tried to make the UX reasonably decent without disrupting existing stacks. There are some new types being created here, including `ICapacityProvider` (interface type) and its concrete type `EC2CapacityProvider` (which is a class users can instantiate). There are also a couple of singleton classes for `FargateCapacityProvider` and `FargateSpotCapacityProvider`.

Closes #5471

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
Add support for EC2 Capacity Providers.

I tried to make the UX reasonably decent without disrupting existing stacks. There are some new types being created here, including `ICapacityProvider` (interface type) and its concrete type `EC2CapacityProvider` (which is a class users can instantiate). There are also a couple of singleton classes for `FargateCapacityProvider` and `FargateSpotCapacityProvider`.

Closes aws#5471

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container feature-request A feature should be added or improved. in-progress This issue is being actively worked on. p1
Projects
None yet