Validate export names are unique

This commit is contained in:
Jessie Nadler 2017-06-02 16:23:42 -04:00
commit c6603c6248
2 changed files with 25 additions and 1 deletions

View file

@ -150,6 +150,7 @@ class CloudFormationBackend(BaseBackend):
role_arn=role_arn,
)
self.stacks[stack_id] = new_stack
self._validate_export_uniqueness(new_stack)
for export in new_stack.exports:
self.exports[export.name] = export
return new_stack
@ -217,6 +218,12 @@ class CloudFormationBackend(BaseBackend):
next_token = str(token + 100) if len(all_exports) > token + 100 else None
return exports, next_token
def _validate_export_uniqueness(self, stack):
new_stack_export_names = [x.name for x in stack.exports]
export_names = self.exports.keys()
if not set(export_names).isdisjoint(new_stack_export_names):
raise ValidationError(stack.stack_id, message='Export names must be unique across a given region')
cloudformation_backends = {}
for region in boto.cloudformation.regions():