tweak Fn::GetAtt to return resource_json if resource is not implemented. DRY

This is better than failing out with a misleading Boto 400 error which should only happen when get_cfn_attribute is called but fails.
This commit is contained in:
Joseph Lawson 2014-10-21 14:51:26 -04:00
commit 20a69255c3
8 changed files with 46 additions and 52 deletions

View file

@ -1,6 +1,5 @@
from __future__ import unicode_literals
from moto.core import BaseBackend
from boto.exception import BotoServerError
class FakeHealthCheck(object):
@ -58,6 +57,7 @@ class FakeLoadBalancer(object):
return self.name
def get_cfn_attribute(self, attribute_name):
from moto.cloudformation.exceptions import UnformattedGetAttTemplateException
if attribute_name == 'CanonicalHostedZoneName':
raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "CanonicalHostedZoneName" ]"')
elif attribute_name == 'CanonicalHostedZoneNameID':
@ -68,9 +68,7 @@ class FakeLoadBalancer(object):
raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "SourceSecurityGroup.GroupName" ]"')
elif attribute_name == 'SourceSecurityGroup.OwnerAlias':
raise NotImplementedError('"Fn::GetAtt" : [ "{0}" , "SourceSecurityGroup.OwnerAlias" ]"')
raise BotoServerError(400,
'Bad Request',
'Template error: resource {0} does not support attribute type {1} in Fn::GetAtt')
raise UnformattedGetAttTemplateException()
class ELBBackend(BaseBackend):