aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

Package command should fail without Transform: AWS::Serverless-2016-10-31

Open janza opened this issue 6 years ago • 4 comments

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.

janza avatar Dec 11 '18 22:12 janza

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::Functions 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.

jfuss avatar Dec 11 '18 22:12 jfuss

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.

janza avatar Dec 11 '18 22:12 janza

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?

jfuss avatar Dec 11 '18 22:12 jfuss

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.

janza avatar Dec 12 '18 19:12 janza

Going to go ahead and close this issue. sam package and sam deploy both operate on native cloudformation resources as well.

sriram-mv avatar Sep 19 '22 19:09 sriram-mv