Build instructions are incorrect for raw CloudFormation
john-tipper opened this issue · comments
Describe the bug
The build instructions for raw CloudFormation state:
sam build --base-dir . --template-file cf-macro/template.yaml
If you do this, SAM will bundle the whole of the project directory into the macro lambda bundle and this will result in a lambda package that exceeds the limit of 250MB when it is extracted and the sam deploy
will fail.
To Reproduce
Steps to reproduce the behavior:
cd
to project root.'- npm install && sam build --base-dir . --template-file cf-macro/template.yaml && sam deploy --guided
Expected behavior
The macro should deploy without error.
Environment:
- OS: Windows
- Node.js Version: 14.17.4
- NPM version: 8.3.2
- Serverless Framework Version: 1.59.0
I think the changes are to either run the build command in the cf-macro directory, or to specify that as the base directory. The template file also needs to have the handler field updated to remove reference to cf-macro.
@john-tipper thanks for reporting! This issue was observed and fixed as part of the work for #97 .
We need to build from the root directory so the core
package can be found. Unfortunately, this meant that lots of unnecessary resources are bundled, making the unzipped package larger than 250MB.
The solution now in place uses esbuild
to package the CF Macro, making the cf-macro
size nice and small and the deployment process much faster.