Throw exception if an update is attempted on a stack in ROLLBACK_COMPLETE

If a stack has a status of ROLLBACK_COMPLETE and you attempt to update
it, the AWS API throws a validation error. This updates moto to have the
same behvaior. We also uncommented a test which tests updating a stack
which passed without any additional modification -- it is unclear why
this test was commented.

Signed-off-by: Jack Lund <jack.lund@getbraintree.com>
This commit is contained in:
Jesse Szwedko 2016-04-11 21:52:03 +00:00 committed by Steve Pulec
commit 6928501973
3 changed files with 28 additions and 2 deletions

View file

@ -9,12 +9,15 @@ class UnformattedGetAttTemplateException(Exception):
class ValidationError(BadRequest):
def __init__(self, name_or_id):
def __init__(self, name_or_id, message=None):
if message is None:
messgae="Stack:{0} does not exist".format(name_or_id),
template = Template(ERROR_RESPONSE)
super(ValidationError, self).__init__()
self.description = template.render(
code="ValidationError",
message="Stack:{0} does not exist".format(name_or_id),
message=message,
)

View file

@ -129,6 +129,10 @@ class CloudFormationResponse(BaseResponse):
else:
stack_body = self._get_param('TemplateBody')
stack = self.cloudformation_backend.get_stack(stack_name)
if stack.status == 'ROLLBACK_COMPLETE':
raise ValidationError(stack.stack_id, message="Stack:{0} is in ROLLBACK_COMPLETE state and can not be updated.".format(stack.stack_id))
stack = self.cloudformation_backend.update_stack(
name=stack_name,
template=stack_body,