-
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
feat(aws-ecs): instance autoscaling and drain hook #1192
Conversation
Make it easy to configure EC2 instance autoscaling for your cluster, and automatically add a Lifecylce Hook Lambda that will delay instance termination until all ECS tasks have drained from the instance. Fixes #1162.
cc @clareliguori and @SoManyHs. I've tested this a bit with the Was that a scheduling fluke, or do the tasks need draining support, or have I been doing something wrong? Setup and Lambda code has been copied and slighly adjusted from: |
The scheduler will attempt to start a new task on a different instance before stopping the one on the draining instance. Check that you had enough spare capacity, new tasks started successfully, etc |
cc @PaulMaddox |
It was running elsewhere too |
But my most important objective right now is to verify the code is ok |
LGTM |
packages/@aws-cdk/aws-autoscaling/test/test.auto-scaling-group.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-ecs/lib/drain-hook/instance-drain-hook.ts
Outdated
Show resolved
Hide resolved
// Invoke Lambda via SNS Topic | ||
const topic = new sns.Topic(this, 'Topic'); | ||
const fn = new lambda.Function(this, 'Function', { | ||
code: lambda.Code.directory(path.join(__dirname, 'lambda-source')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- .directory is deprecated (use
.asset
) - Also, for L2s, if possible, I think we should prefer inline code instead of assets to reduce the surface area
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree!
Waiting for the build... |
Make it easy to configure EC2 instance autoscaling for your cluster,
and automatically add a Lifecylce Hook Lambda that will delay
instance termination until all ECS tasks have drained from the instance.
Fixes #1162.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.