diff --git a/moto/elbv2/models.py b/moto/elbv2/models.py index a34926ea2..a612ba93a 100644 --- a/moto/elbv2/models.py +++ b/moto/elbv2/models.py @@ -274,6 +274,12 @@ class FakeLoadBalancer(BaseModel): load_balancer = elbv2_backend.create_load_balancer(name, security_groups, subnet_ids, scheme=scheme) return load_balancer + def get_cfn_attribute(self, attribute_name): + attributes = { + 'DNSName': self.dns_name, + 'LoadBalancerName': self.name, + } + return attributes[attribute_name] class ELBv2Backend(BaseBackend): diff --git a/tests/test_cloudformation/test_cloudformation_stack_integration.py b/tests/test_cloudformation/test_cloudformation_stack_integration.py index cd3f61b9e..2d44fb5b7 100644 --- a/tests/test_cloudformation/test_cloudformation_stack_integration.py +++ b/tests/test_cloudformation/test_cloudformation_stack_integration.py @@ -2119,6 +2119,16 @@ def test_stack_spot_fleet(): def test_stack_elbv2_resources_integration(): alb_template = { "AWSTemplateFormatVersion": "2010-09-09", + "Outputs": { + "albdns": { + "Description": "Load balanacer DNS", + "Value": {"Fn::GetAtt": ["alb", "DNSName"]}, + }, + "albname": { + "Description": "Load balancer name", + "Value": {"Fn::GetAtt": ["alb", "LoadBalancerName"]}, + }, + }, "Resources": { "alb": { "Type": "AWS::ElasticLoadBalancingV2::LoadBalancer", @@ -2207,8 +2217,8 @@ def test_stack_elbv2_resources_integration(): } alb_template_json = json.dumps(alb_template) - conn = boto3.client("cloudformation", "us-west-1") - conn.create_stack( + cfn_conn = boto3.client("cloudformation", "us-west-1") + cfn_conn.create_stack( StackName="elb_stack", TemplateBody=alb_template_json, ) @@ -2246,3 +2256,11 @@ def test_stack_elbv2_resources_integration(): "Type": "forward", "TargetGroupArn": target_groups[0]['TargetGroupArn'] }]) + + # test outputs + stacks = cfn_conn.describe_stacks(StackName='elb_stack')['Stacks'] + len(stacks).should.equal(1) + stacks[0]['Outputs'].should.equal([ + {'OutputKey': 'albdns', 'OutputValue': load_balancers[0]['DNSName']}, + {'OutputKey': 'albname', 'OutputValue': load_balancers[0]['LoadBalancerName']}, + ])