Skip to content

Commit

Permalink
Autoscaling: update_group() now validates that the Group exists (#7983)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored Aug 15, 2024
1 parent a0cd54c commit f5df94a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions moto/autoscaling/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,8 @@ def update_auto_scaling_group(
"Valid requests must contain either LaunchTemplate, LaunchConfigurationName "
"or MixedInstancesPolicy parameter."
)
if name not in self.autoscaling_groups:
raise ValidationError("AutoScalingGroup name not found - null")

group = self.autoscaling_groups[name]
group.update(
Expand Down
18 changes: 17 additions & 1 deletion tests/test_autoscaling/test_autoscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from moto import mock_aws
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
from tests import EXAMPLE_AMI_ID
from tests import EXAMPLE_AMI_ID, aws_verified

from .utils import setup_instance_with_networking, setup_networking

Expand Down Expand Up @@ -651,6 +651,22 @@ def test_update_autoscaling_group_max_size_desired_capacity_change():
assert len(group["Instances"]) == 5


@aws_verified
@pytest.mark.aws_verified
def test_update_unknown_group():
client = boto3.client("autoscaling", region_name="us-east-1")
with pytest.raises(ClientError) as exc:
client.update_auto_scaling_group(
AutoScalingGroupName="fake-asg",
MinSize=2,
MaxSize=2,
DesiredCapacity=2,
)
err = exc.value.response["Error"]
assert err["Code"] == "ValidationError"
assert err["Message"] == "AutoScalingGroup name not found - null"


@mock_aws
def test_autoscaling_describe_policies():
mocked_networking = setup_networking()
Expand Down

0 comments on commit f5df94a

Please sign in to comment.