From fd21ccb5b71fb9c06898f507e1e71954860d0995 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Wed, 20 Mar 2024 21:45:02 +0100 Subject: [PATCH] CloudFormation: Return Description field in Outputs (#7489) --- moto/cloudformation/responses.py | 1 + .../test_cloudformation_custom_resources.py | 6 +++++- tests/test_ec2/test_ec2_cloudformation.py | 7 ++++++- tests/test_emr/test_emr_cloudformation.py | 6 +++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/moto/cloudformation/responses.py b/moto/cloudformation/responses.py index b848f5e14..8373ffb3c 100644 --- a/moto/cloudformation/responses.py +++ b/moto/cloudformation/responses.py @@ -818,6 +818,7 @@ DESCRIBE_STACKS_TEMPLATE = """ {{ output.key }} {{ output.value }} + {% if output.description %}{{ output.description }}{% endif %} {% endfor %} diff --git a/tests/test_cloudformation/test_cloudformation_custom_resources.py b/tests/test_cloudformation/test_cloudformation_custom_resources.py index b5da00d38..e0820f825 100644 --- a/tests/test_cloudformation/test_cloudformation_custom_resources.py +++ b/tests/test_cloudformation/test_cloudformation_custom_resources.py @@ -165,7 +165,11 @@ def test_create_custom_lambda_resource__verify_manual_request(): stack = cf.describe_stacks(StackName=stack_id)["Stacks"][0] assert stack["StackStatus"] == "CREATE_COMPLETE" assert stack["Outputs"] == [ - {"OutputKey": "infokey", "OutputValue": "resultfromthirdpartysystem"} + { + "OutputKey": "infokey", + "OutputValue": "resultfromthirdpartysystem", + "Description": "A very important value", + }, ] # AWSlambda will not have logged anything diff --git a/tests/test_ec2/test_ec2_cloudformation.py b/tests/test_ec2/test_ec2_cloudformation.py index 215872fa9..f01c04b29 100644 --- a/tests/test_ec2/test_ec2_cloudformation.py +++ b/tests/test_ec2/test_ec2_cloudformation.py @@ -764,7 +764,11 @@ def test_vpc_endpoint_creation(): outputs = cf.describe_stacks(StackName=stack_name)["Stacks"][0]["Outputs"] assert len(outputs) == 1 - assert outputs[0] == {"OutputKey": "EndpointId", "OutputValue": vpc_endpoint_id} + assert outputs[0] == { + "OutputKey": "EndpointId", + "OutputValue": vpc_endpoint_id, + "Description": "Id of the endpoint created", + } endpoint = ec2_client.describe_vpc_endpoints(VpcEndpointIds=[vpc_endpoint_id])[ "VpcEndpoints" @@ -836,6 +840,7 @@ def test_launch_template_create(): assert outputs[0] == { "OutputKey": "LaunchTemplateId", "OutputValue": launch_template_id, + "Description": "The ID of the created launch template", } launch_template = ec2.describe_launch_templates( diff --git a/tests/test_emr/test_emr_cloudformation.py b/tests/test_emr/test_emr_cloudformation.py index b9c2751d5..7288e9a53 100644 --- a/tests/test_emr/test_emr_cloudformation.py +++ b/tests/test_emr/test_emr_cloudformation.py @@ -53,7 +53,11 @@ def test_create_simple_cluster__using_cloudformation(): # Verify outputs stack = cf.describe_stacks(StackName="teststack")["Stacks"][0] - assert {"OutputKey": "ClusterId", "OutputValue": cluster_id} in stack["Outputs"] + assert { + "OutputKey": "ClusterId", + "OutputValue": cluster_id, + "Description": "Cluster info", + } in stack["Outputs"] # Verify EMR Cluster cl = emr.describe_cluster(ClusterId=cluster_id)["Cluster"]