On malformed CloudFormation, the CLI gives some pretty undecipherable output.
$ aws --version
aws-cli/1.11.24 Python/2.7.10 Darwin/16.1.0 botocore/1.4.81
In a directory containing:
ServerlessTest.zip (zip of this lambda source)
and
example.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
TestFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs4.3
Environment:
Variables:
S3_BUCKET: _my-bucket_
Note that "TestFunction" should be indented, but isn't.
I ran the following command
$ aws cloudformation package --template-file example.yaml --output-template-file serverless-output.yaml --s3-bucket _my-bucket_
This gives the unfriendly output:
'NoneType' object has no attribute 'items'
With --debug added, this is narrowed down to:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 197, in main
return command_table[parsed_args.command](remaining, parsed_args)
File "/Library/Python/2.7/site-packages/awscli/clidriver.py", line 333, in __call__
return command_table[parsed_args.operation](remaining, parsed_globals)
File "/Library/Python/2.7/site-packages/awscli/customizations/commands.py", line 187, in __call__
return self._run_main(parsed_args, parsed_globals)
File "/Library/Python/2.7/site-packages/awscli/customizations/cloudformation/package.py", line 125, in _run_main
exported_str = self._export(template_path)
File "/Library/Python/2.7/site-packages/awscli/customizations/cloudformation/package.py", line 141, in _export
exported_template = template.export()
File "/Library/Python/2.7/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 399, in export
for resource_id, resource in self.template_dict["Resources"].items():
AttributeError: 'NoneType' object has no attribute 'items'
2016-12-04 16:03:57,035 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255
'NoneType' object has no attribute 'items'
Makes sense. We will look into improving the error message on malformed cloudformation templates.
Had a similar error message when I left a resource without anything in it.
'NoneType' object has no attribute 'get'
Had the same problem:
'NoneType' object has no attribute 'items'
Resolution was to fix indentation on a resource. Thanks for the help!
Same here, it would be nice with a better error message.
Please fix the error, its very misleading
Most helpful comment
Makes sense. We will look into improving the error message on malformed cloudformation templates.