aws-actions / aws-cloudformation-github-deploy

Deploys AWS CloudFormation Stacks
MIT License
248 stars 121 forks source link

Feature Request: AWS SAM support #50

Open chrisbelyea opened 3 years ago

chrisbelyea commented 3 years ago

This Action isn't compatible with SAM templates that use a local file path for the CodeUri property of a AWS::Serverless::Function resource.

The CodeUi property states

The function code's Amazon S3 URI, local file path, or FunctionCode object.

If an Amazon S3 URI or FunctionCode object is provided, the Amazon S3 object referenced must be a valid Lambda deployment package.

If a local file path is provided, for the code to be transformed properly the template must go through the workflow that includes the sam deploy or sam package command.

(emphasis added)

Attempting to use this Action with a Serverless transform template that contains a AWS::Serverless::Function resource using a local path for CodeUri results in CloudFormation producing this error during stack creation:

Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document.
Number of errors found: 1.
Resource with id [MyLambdaFunction] is invalid. 'CodeUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.

Somewhat related to #32 and #33.

Since this requires SAM CLI to correctly deploy a stack, this functionality might instead belong in a separate aws-sam-github-deploy action.

tmclaugh commented 4 weeks ago

In case anyone else runs into this issue, perform sam package and use --output-template-file to output the template to a file. Then pass that template file to this action.