From 0b84eec6ab055307d220039ba4a7766adc021da3 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Thu, 9 Nov 2023 22:24:06 -0100 Subject: [PATCH] EC2: describe_hosts() now returns the AllocationTime-attribute (#7012) --- moto/ec2/models/hosts.py | 2 ++ moto/ec2/responses/hosts.py | 1 + tests/test_ec2/test_hosts.py | 1 + 3 files changed, 4 insertions(+) diff --git a/moto/ec2/models/hosts.py b/moto/ec2/models/hosts.py index d44d39199..b3183fda7 100644 --- a/moto/ec2/models/hosts.py +++ b/moto/ec2/models/hosts.py @@ -1,5 +1,6 @@ from .core import TaggedEC2Resource from ..utils import generic_filter, random_dedicated_host_id +from moto.core.utils import unix_time from typing import Any, Dict, List, Optional @@ -21,6 +22,7 @@ class Host(TaggedEC2Resource): self.instance_family: Optional[str] = instance_family self.auto_placement = auto_placement or "on" self.ec2_backend = backend + self.allocation_time = unix_time() def release(self) -> None: self.state = "released" diff --git a/moto/ec2/responses/hosts.py b/moto/ec2/responses/hosts.py index cb1825c5b..faa856081 100644 --- a/moto/ec2/responses/hosts.py +++ b/moto/ec2/responses/hosts.py @@ -66,6 +66,7 @@ EC2_DESCRIBE_HOSTS = """