Closed mixja closed 5 years ago
@mixja Thanks for the report. Looks like https://github.com/awslabs/serverless-application-model/pull/856 broke the integration. Specifically, the prepare_plugins
added an optional value of parameters and defaults to an empty dictionary. We have a wrapper that ends up calling this method: https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/commands/local/lib/sam_base_provider.py#L62 which calls https://github.com/awslabs/aws-sam-cli/blob/develop/samcli/lib/samlib/wrapper.py#L64.
We will need to change how we run plugins now.
As a side note: Why are you running build in this case? The template you provided does not have any functions in it?
Thanks - it would affect SAM templates that have both functions and other Serverless applications - I just left out other resources to focus on the actual issue.
Same error seems to be happening when using parameter substitution in ApplicationId
, so the following block causes it to explode (even when the parameter is properly set up)
ImageMagick:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: !Sub "arn:aws:serverlessrepo:us-east-1:${ImageMagickLayerAppId}"
SemanticVersion: 1.0.0
this works OK:
ImageMagick:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:145266761615:applications/image-magick-lambda-layer
SemanticVersion: 1.0.0
here's some system info if it's helpful
$ sam --version
SAM CLI, version 0.16.1
$ aws --version
aws-cli/1.16.162 Python/3.7.1 Darwin/18.5.0 botocore/1.12.152
actual stack trace
2019-05-21 00:22:20 Plugin 'ServerlessAppPlugin' raised an exception: unhashable type: 'dict'
Traceback (most recent call last):
File "/project/pythonenv/lib/python3.7/site-packages/samtranslator/plugins/__init__.py", line 130, in act
getattr(plugin, method_name)(*args, **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/samtranslator/plugins/application/serverless_app_plugin.py", line 85, in on_before_transform_template
if key not in self._applications:
TypeError: unhashable type: 'dict'
Traceback (most recent call last):
File "/project/pythonenv/bin/sam", line 10, in <module>
sys.exit(cli())
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/samcli/commands/build/command.py", line 103, in cli
skip_pull_image, parameter_overrides, mode) # pragma: no cover
File "/project/pythonenv/lib/python3.7/site-packages/samcli/commands/build/command.py", line 136, in do_cli
mode=mode) as ctx:
File "/project/pythonenv/lib/python3.7/site-packages/samcli/commands/build/build_context.py", line 65, in __enter__
self._function_provider = SamFunctionProvider(self._template_dict, self._parameter_overrides)
File "/project/pythonenv/lib/python3.7/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 46, in __init__
self.template_dict = SamBaseProvider.get_template(template_dict, parameter_overrides)
File "/project/pythonenv/lib/python3.7/site-packages/samcli/commands/local/lib/sam_base_provider.py", line 62, in get_template
template_dict = SamTranslatorWrapper(template_dict).run_plugins()
File "/project/pythonenv/lib/python3.7/site-packages/samcli/lib/samlib/wrapper.py", line 67, in run_plugins
parser.parse(template_copy, all_plugins) # parse() will run all configured plugins
File "/project/pythonenv/lib/python3.7/site-packages/samcli/lib/samlib/wrapper.py", line 120, in parse
sam_plugins.act(LifeCycleEvents.before_transform_template, sam_template)
File "/project/pythonenv/lib/python3.7/site-packages/samtranslator/plugins/__init__.py", line 136, in act
raise ex
File "/project/pythonenv/lib/python3.7/site-packages/samtranslator/plugins/__init__.py", line 130, in act
getattr(plugin, method_name)(*args, **kwargs)
File "/project/pythonenv/lib/python3.7/site-packages/samtranslator/plugins/application/serverless_app_plugin.py", line 85, in on_before_transform_template
if key not in self._applications:
TypeError: unhashable type: 'dict'
make: *** [deploy] Error 1
This should be fixed as per https://github.com/awslabs/serverless-application-model/issues/897#issuecomment-487137339. The next sam-cli release v0.20.0 upgrades to the latest sam version and should address this issue.
Description
When you attempt to reference a parameter for the
SemanticVersion
property of theLocation
object, SAM processing fails with an internal transform failure.Note as per https://github.com/awslabs/serverless-application-model/issues/897, support for this has been recently added to SAM so I expect SAM CLI just needs to be updated to support this change.
Steps to reproduce
Attempt to run
sam build
for following template:Observed result
sam build --debug
fails with the following:Expected result
Template should be processed successfully.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 0.15.0