question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ecs] unable to specify update policy when adding ASG capacity to ECS cluster

See original GitHub issue

The following code forces the updateType prop when constructing the subsequent ASG cluster:

https://github.com/aws/aws-cdk/blob/0b058f372a41092a383706dc35e32e0573b962fe/packages/%40aws-cdk/aws-ecs/lib/cluster.ts#L203

The updateType prop is of type UpdateType which is now deprecated in favor of passing an UpdatePolicy but the two arguments are mutually exclusive. If you try to pass an updatePolcy prop into this function, the following error is output:

Error: Cannot set 'signals'/'updatePolicy' and 'updateType' together. Prefer 'signals'/'updatePolicy'

The only way for callers to override the default is to supply an updateType prop to override the Cluster’s default behavior when using .addCapacity(...). This means the caller must use a deprecated API which is not ideal and causes linter warnings unless they are dismissed/disabled.

I believe this could be fixed by making this wrapper method aware of the mutually-exclusive props and if neither is specified, pass updatePolicy: UpdatePolicy.rollingUpdate().

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
solovievvcommented, Feb 26, 2021

My solution for python CDK:

        auto_scaling_group = cluster.add_capacity(...)
        cfn_asg_resource = auto_scaling_group.node.default_child
        cfn_asg_resource.add_override(
            path="UpdatePolicy",
            value={
                "AutoScalingRollingUpdate": {
                    "MinInstancesInService": "2",
                    "MaxBatchSize": "1",
                    "PauseTime": "PT10M0S",
                    "WaitOnResourceSignals": "false",
                    "SuspendProcesses": [
                        "HealthCheck",
                        "ReplaceUnhealthy",
                        "AZRebalance",
                        "AlarmNotification",
                        "ScheduledActions"
                    ]
                }
            }
        )
        cfn_asg_resource.add_deletion_override("UpdatePolicy.AutoScalingReplacingUpdate")
        cfn_asg_resource.add_deletion_override("UpdatePolicy.AutoScalingScheduledAction")
2reactions
evaydecommented, Jan 9, 2021

If you came here from google, this would work:

    this.cluster.addCapacity("AppCap", {
      ...
      updateType: undefined,
      updatePolicy: autoscaling.UpdatePolicy.rollingUpdate(),
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot scaling issues with ECS capacity providers
To resolve this issue, update the ECS service using the AWS CLI commands update-service, run-task, or put-cluster-capacity-providers.
Read more >
How to Configure Auto-scaling for AWS ECS Service with ...
Update the ECS cluster to use the capacity provider we created. Open 'clusterDemo' cluster and click 'Update cluster'. Change default capacity ...
Read more >
Auto Scaling group capacity providers - 亚马逊云科技
Amazon ECS capacity providers can use Auto Scaling groups to manage the Amazon EC2 instances registered to their clusters. You can use the...
Read more >
Deploy ECS Cluster Auto Scaling - Amazon ECS Workshop
In order to create a capacity provider with cluster auto scaling enabled, we need to have an auto scaling group created prior. We...
Read more >
Amazon ECS Cluster Auto Scaling with a Capacity Provider
You can now scale your Amazon Elastic Container Service ( ECS ) clusters (as well as your services) automatically. In this AWS video...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found