aws-sam-cli
aws-sam-cli copied to clipboard
Package command should fail without Transform: AWS::Serverless-2016-10-31
Description
Running aws cloudformation package command should fail if Transform: AWS::Serverless-2016-10-31
directive is not present in the template or, even better, it should add the directive automatically. Running deploy command without the transform present will fail with not that obvious error about Unrecognized resource types
. This is hard to debug and not user friendly.
Steps to reproduce
Run aws cloudformation package
or sam package
command on a template without the Transform directive.
Expected result
Packaging command should fail with a friendly error message.
The package command is not tied to only resources that require the Transform: AWS::Serverless-2016-10-31
. I can define my template with AWS::Lambda::Function
s instead and still want package to do it's job. Adding the Transform does not make sense in this case because where are no AWS::Serverless::*
resources.
Ah, that makes sense. Would it be an option for deploy command to complain about this then? Cause that's the one that's giving the somewhat unclear error about Unrecognized resource types.
I think it is a reasonable thing for deploy
to do. Or even further in the workflow, so it can be caught during testing (its kind of strange we always run the aws-sam-translator
even if the Transform
key doesn't exist. It is defiantly an improvement to make, just not 100% sure on the proper place for it at the moment.
What are your thoughts?
For developer experience it would be nice to fail early during package
so if translator detects some Serverless resources but no Transform key it should at least emit a warning that there is something wrong.
But in the end deploy
should probably also show a friendlier error message I think.
Going to go ahead and close this issue. sam package
and sam deploy
both operate on native cloudformation resources as well.