Sets autoscalinggroup CreatedTime during creation. (#7478)
This commit is contained in:
parent
5d4ea2f393
commit
caac727530
@ -1,5 +1,6 @@
|
||||
import itertools
|
||||
from collections import OrderedDict
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict, List, Optional, Tuple, Union
|
||||
|
||||
from moto.core.base_backend import BackendDict, BaseBackend
|
||||
@ -439,6 +440,7 @@ class FakeAutoScalingGroup(CloudFormationModel):
|
||||
mixed_instance_policy: Optional[Dict[str, Any]],
|
||||
capacity_rebalance: bool,
|
||||
new_instances_protected_from_scale_in: bool = False,
|
||||
created_time: datetime = datetime.now(),
|
||||
):
|
||||
self.autoscaling_backend = autoscaling_backend
|
||||
self.ec2_backend = ec2_backend
|
||||
@ -483,6 +485,7 @@ class FakeAutoScalingGroup(CloudFormationModel):
|
||||
|
||||
self.metrics: List[str] = []
|
||||
self.warm_pool: Optional[FakeWarmPool] = None
|
||||
self.created_time = created_time
|
||||
|
||||
@property
|
||||
def tags(self) -> List[Dict[str, str]]:
|
||||
|
@ -833,7 +833,7 @@ DESCRIBE_AUTOSCALING_GROUPS_TEMPLATE = """<DescribeAutoScalingGroupsResponse xml
|
||||
</SuspendedProcesses>
|
||||
<AutoScalingGroupName>{{ group.name }}</AutoScalingGroupName>
|
||||
<HealthCheckType>{{ group.health_check_type }}</HealthCheckType>
|
||||
<CreatedTime>2013-05-06T17:47:15.107Z</CreatedTime>
|
||||
<CreatedTime>{{ group.created_time }}</CreatedTime>
|
||||
{% if group.launch_config_name %}
|
||||
<LaunchConfigurationName>{{ group.launch_config_name }}</LaunchConfigurationName>
|
||||
{% elif group.mixed_instance_policy %}
|
||||
|
@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
from uuid import uuid4
|
||||
|
||||
import boto3
|
||||
@ -1325,3 +1326,28 @@ def test_create_template_with_block_device():
|
||||
# Our Ebs-volume
|
||||
assert volumes[1]["VolumeType"] == "gp3"
|
||||
assert volumes[1]["Size"] == 20
|
||||
|
||||
|
||||
@mock_aws
|
||||
def test_sets_created_time():
|
||||
mocked_networking = setup_networking()
|
||||
conn = boto3.client("autoscaling", region_name="us-east-1")
|
||||
conn.create_launch_configuration(
|
||||
LaunchConfigurationName="TestLC",
|
||||
ImageId=EXAMPLE_AMI_ID,
|
||||
InstanceType="t2.medium",
|
||||
)
|
||||
|
||||
conn.create_auto_scaling_group(
|
||||
AutoScalingGroupName="TestGroup1",
|
||||
MinSize=1,
|
||||
MaxSize=2,
|
||||
LaunchConfigurationName="TestLC",
|
||||
VPCZoneIdentifier=mocked_networking["subnet1"],
|
||||
)
|
||||
|
||||
asgs = conn.describe_auto_scaling_groups()["AutoScalingGroups"]
|
||||
assert len(asgs) == 1
|
||||
assert asgs[0]["CreatedTime"] != datetime.strptime(
|
||||
"2013-05-06T17:47:15.107Z", "%Y-%m-%dT%H:%M:%S.%f%z"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user