Fixed CF creation to trap imports of non-existent values
This commit is contained in:
parent
b6909ff64c
commit
da8bd545bf
4 changed files with 101 additions and 2 deletions
|
|
@ -33,6 +33,18 @@ class MissingParameterError(BadRequest):
|
|||
)
|
||||
|
||||
|
||||
class ExportNotFound(BadRequest):
|
||||
"""Exception to raise if a template tries to import a non-existent export"""
|
||||
|
||||
def __init__(self, export_name):
|
||||
template = Template(ERROR_RESPONSE)
|
||||
super(ExportNotFound, self).__init__()
|
||||
self.description = template.render(
|
||||
code='ExportNotFound',
|
||||
message="No export named {0} found.".format(export_name)
|
||||
)
|
||||
|
||||
|
||||
ERROR_RESPONSE = """<ErrorResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
|
||||
<Error>
|
||||
<Type>Sender</Type>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class FakeStack(BaseModel):
|
|||
resource_status_reason="User Initiated")
|
||||
|
||||
self.description = self.template_dict.get('Description')
|
||||
self.cross_stack_resources = cross_stack_resources or []
|
||||
self.cross_stack_resources = cross_stack_resources or {}
|
||||
self.resource_map = self._create_resource_map()
|
||||
self.output_map = self._create_output_map()
|
||||
self._add_stack_event("CREATE_COMPLETE")
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ from moto.s3 import models as s3_models
|
|||
from moto.sns import models as sns_models
|
||||
from moto.sqs import models as sqs_models
|
||||
from .utils import random_suffix
|
||||
from .exceptions import MissingParameterError, UnformattedGetAttTemplateException, ValidationError
|
||||
from .exceptions import ExportNotFound, MissingParameterError, UnformattedGetAttTemplateException, ValidationError
|
||||
from boto.cloudformation.stack import Output
|
||||
|
||||
MODEL_MAP = {
|
||||
|
|
@ -206,6 +206,8 @@ def clean_json(resource_json, resources_map):
|
|||
values = [x.value for x in resources_map.cross_stack_resources.values() if x.name == cleaned_val]
|
||||
if any(values):
|
||||
return values[0]
|
||||
else:
|
||||
raise ExportNotFound(cleaned_val)
|
||||
|
||||
if 'Fn::GetAZs' in resource_json:
|
||||
region = resource_json.get('Fn::GetAZs') or DEFAULT_REGION
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue