diff --git a/samtranslator/model/sam_resources.py b/samtranslator/model/sam_resources.py index d098c23d3..ce4ffa3e9 100644 --- a/samtranslator/model/sam_resources.py +++ b/samtranslator/model/sam_resources.py @@ -878,7 +878,7 @@ def _validate_deployment_preference_and_add_update_policy( ) if deployment_preference_collection.get(self.logical_id).enabled: - if self.AutoPublishAlias is None: + if not self.AutoPublishAlias: raise InvalidResourceException( self.logical_id, "'DeploymentPreference' requires AutoPublishAlias property to be specified." ) diff --git a/tests/translator/input/error_auto_publish_alias_empty_string.yaml b/tests/translator/input/error_auto_publish_alias_empty_string.yaml new file mode 100644 index 000000000..a67ea4084 --- /dev/null +++ b/tests/translator/input/error_auto_publish_alias_empty_string.yaml @@ -0,0 +1,10 @@ +Resources: + MinimalFunction: + Type: 'AWS::Serverless::Function' + Properties: + CodeUri: s3://sam-demo-bucket/hello.zip + Handler: hello.handler + Runtime: python2.7 + AutoPublishAlias: '' + DeploymentPreference: + Type: AllAtOnce \ No newline at end of file diff --git a/tests/translator/output/error_auto_publish_alias_empty_string.json b/tests/translator/output/error_auto_publish_alias_empty_string.json new file mode 100644 index 000000000..46183aa60 --- /dev/null +++ b/tests/translator/output/error_auto_publish_alias_empty_string.json @@ -0,0 +1,3 @@ +{ + "errorMessage": "Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [MinimalFunction] is invalid. 'DeploymentPreference' requires AutoPublishAlias property to be specified." +} \ No newline at end of file