Handle change of ASG desired capacity on min and max size update

A change in UpdateAutoScalingGroup:
* if a value for MinSize is specified without specifying a value for
DesiredCapacity, and the new MinSize is larger than the current size of
the group, set the group's DesiredCapacity to the new MinSize value
* if a value for MaxSize is specified without specifying a value for
DesiredCapacity, and the new MaxSize is smaller than the current size of
the group, set the group's DesiredCapacity to the new MaxSize value
This commit is contained in:
Berislav Kovacki 2019-07-16 09:12:03 +02:00
commit 1b3157ced0
2 changed files with 62 additions and 0 deletions

View file

@ -279,6 +279,12 @@ class FakeAutoScalingGroup(BaseModel):
if min_size is not None:
self.min_size = min_size
if desired_capacity is None:
if min_size is not None and min_size > len(self.instance_states):
desired_capacity = min_size
if max_size is not None and max_size < len(self.instance_states):
desired_capacity = max_size
if launch_config_name:
self.launch_config = self.autoscaling_backend.launch_configurations[
launch_config_name]