Add proper CFN attribute handling to elbv2.FakeLoadBalancer (#1341)
This commit is contained in:
parent
8ee05e22af
commit
7b1ec157b8
@ -293,11 +293,32 @@ class FakeLoadBalancer(BaseModel):
|
||||
return load_balancer
|
||||
|
||||
def get_cfn_attribute(self, attribute_name):
|
||||
attributes = {
|
||||
'DNSName': self.dns_name,
|
||||
'LoadBalancerName': self.name,
|
||||
}
|
||||
return attributes[attribute_name]
|
||||
'''
|
||||
Implemented attributes:
|
||||
* DNSName
|
||||
* LoadBalancerName
|
||||
|
||||
Not implemented:
|
||||
* CanonicalHostedZoneID
|
||||
* LoadBalancerFullName
|
||||
* SecurityGroups
|
||||
|
||||
This method is similar to models.py:FakeLoadBalancer.get_cfn_attribute()
|
||||
'''
|
||||
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
|
||||
not_implemented_yet = [
|
||||
'CanonicalHostedZoneID',
|
||||
'LoadBalancerFullName',
|
||||
'SecurityGroups',
|
||||
]
|
||||
if attribute_name == 'DNSName':
|
||||
return self.dns_name
|
||||
elif attribute_name == 'LoadBalancerName':
|
||||
return self.name
|
||||
elif attribute_name in not_implemented_yet:
|
||||
raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "%s" ]"' % attribute_name)
|
||||
else:
|
||||
raise UnformattedGetAttTemplateException()
|
||||
|
||||
|
||||
class ELBv2Backend(BaseBackend):
|
||||
|
@ -2128,6 +2128,10 @@ def test_stack_elbv2_resources_integration():
|
||||
"Description": "Load balancer name",
|
||||
"Value": {"Fn::GetAtt": ["alb", "LoadBalancerName"]},
|
||||
},
|
||||
"canonicalhostedzoneid": {
|
||||
"Description": "Load balancer canonical hosted zone ID",
|
||||
"Value": {"Fn::GetAtt": ["alb", "CanonicalHostedZoneID"]},
|
||||
},
|
||||
},
|
||||
"Resources": {
|
||||
"alb": {
|
||||
|
Loading…
Reference in New Issue
Block a user