EC2: Allow ASG to be created without specifying a Template version (#5385)
This commit is contained in:
parent
cd08144d93
commit
0d393e00b0
@ -484,7 +484,7 @@ class FakeAutoScalingGroup(CloudFormationModel):
|
||||
self.launch_template = self.ec2_backend.get_launch_template_by_name(
|
||||
launch_template_name
|
||||
)
|
||||
self.launch_template_version = launch_template["version"]
|
||||
self.launch_template_version = launch_template.get("version") or "$Default"
|
||||
|
||||
@staticmethod
|
||||
def __set_string_propagate_at_launch_booleans_on_tags(tags):
|
||||
|
@ -771,6 +771,33 @@ def test_create_auto_scaling_from_template_version__default():
|
||||
response["LaunchTemplate"].should.have.key("Version").equals("$Default")
|
||||
|
||||
|
||||
@mock_ec2
|
||||
@mock_autoscaling
|
||||
def test_create_auto_scaling_from_template_version__no_version():
|
||||
ec2_client = boto3.client("ec2", region_name="us-west-1")
|
||||
launch_template_name = "tester"
|
||||
ec2_client.create_launch_template(
|
||||
LaunchTemplateName=launch_template_name,
|
||||
LaunchTemplateData={"ImageId": EXAMPLE_AMI_ID, "InstanceType": "t2.medium"},
|
||||
)
|
||||
asg_client = boto3.client("autoscaling", region_name="us-west-1")
|
||||
asg_client.create_auto_scaling_group(
|
||||
AutoScalingGroupName="name",
|
||||
DesiredCapacity=1,
|
||||
MinSize=1,
|
||||
MaxSize=1,
|
||||
LaunchTemplate={"LaunchTemplateName": launch_template_name},
|
||||
AvailabilityZones=["us-west-1a"],
|
||||
)
|
||||
|
||||
response = asg_client.describe_auto_scaling_groups(AutoScalingGroupNames=["name"])[
|
||||
"AutoScalingGroups"
|
||||
][0]
|
||||
response.should.have.key("LaunchTemplate")
|
||||
# We never specified the version - this is what it defaults to
|
||||
response["LaunchTemplate"].should.have.key("Version").equals("$Default")
|
||||
|
||||
|
||||
@mock_autoscaling
|
||||
@mock_ec2
|
||||
def test_create_autoscaling_group_no_template_ref():
|
||||
|
Loading…
Reference in New Issue
Block a user