From 6e6ed28d790b29e99b400947b0378345432f9bc0 Mon Sep 17 00:00:00 2001 From: Clive Li Date: Tue, 13 Feb 2018 17:28:56 +1100 Subject: [PATCH] Use the TemplateBody by default it exist serverless cli use the PUT + TemplateBody + TemplateURL to upload cloudformation template This fix try to get the TemplateBody from the request first, if not exist, fetch the one from s3 bucket --- AUTHORS.md | 1 + moto/cloudformation/responses.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 1771d1a78..710cf5dcb 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -49,3 +49,4 @@ Moto is written by Steve Pulec with contributions from: * [Michael van Tellingen](https://github.com/mvantellingen) * [Jessie Nadler](https://github.com/nadlerjessie) * [Alex Morken](https://github.com/alexmorken) +* [Clive Li](https://github.com/cliveli) diff --git a/moto/cloudformation/responses.py b/moto/cloudformation/responses.py index 07d263652..73d1d2c2b 100644 --- a/moto/cloudformation/responses.py +++ b/moto/cloudformation/responses.py @@ -221,13 +221,12 @@ class CloudFormationResponse(BaseResponse): stack_name = self._get_param('StackName') role_arn = self._get_param('RoleARN') template_url = self._get_param('TemplateURL') + stack_body = self._get_param('TemplateBody') if self._get_param('UsePreviousTemplate') == "true": stack_body = self.cloudformation_backend.get_stack( stack_name).template - elif template_url: + elif not stack_body and template_url: stack_body = self._get_stack_from_s3_url(template_url) - else: - stack_body = self._get_param('TemplateBody') parameters = dict([ (parameter['parameter_key'], parameter['parameter_value'])