diff --git a/tests/conftest.py b/tests/conftest.py index 1a0a6bb2e75..1b5dcafe713 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,7 +77,12 @@ def pytest_addoption(parser): def pytest_report_header(): """Pytest hook to print relevant metadata in the logs""" - return f"EC2 AMI: {global_props.ami}" + return "\n".join( + [ + f"EC2 AMI: {global_props.ami}", + f"EC2 Instance ID: {global_props.instance_id}", + ] + ) @pytest.hookimpl(wrapper=True, tryfirst=True) diff --git a/tests/framework/properties.py b/tests/framework/properties.py index 28310a741f3..29041ab6e64 100644 --- a/tests/framework/properties.py +++ b/tests/framework/properties.py @@ -92,9 +92,11 @@ def __init__(self): self.environment = self._detect_environment() if self.is_ec2: self.instance = imdsv2_get("/meta-data/instance-type") + self.instance_id = imdsv2_get("/meta-data/instance-id") self.ami = imdsv2_get("/meta-data/ami-id") else: self.instance = "NA" + self.instance_id = "NA" self.ami = "NA" @property