Troubleshooting Common Issues in AWS – AWS SAM CLI
AWS Serverless Application Model (SAM) Command Line Interface (CLI) is a tool that you can use to create, build, and deploy serverless applications using the AWS SAM specification. The AWS SAM specification is a model for defining serverless applications, and the SAM CLI is a command line tool that you can use to work with the specification and build serverless applications.
With the SAM CLI, you can create new serverless applications from scratch, or you can use it to build and deploy existing applications that are defined using the AWS SAM specification. The SAM CLI provides a number of useful features, including:
- A command line interface for creating, building, and deploying serverless applications
- A local development environment for testing serverless applications locally before deploying them to the cloud
- Support for debugging serverless applications using your preferred debugger
- Integration with AWS CloudFormation, which allows you to deploy your applications to the cloud using familiar AWS tools
- Support for deploying serverless applications to multiple AWS regions and accounts
Overall, the SAM CLI is a powerful tool that can help you streamline the process of developing and deploying serverless applications on AWS.
Troubleshooting AWS – AWS SAM CLI with the Lightrun Developer Observability Platform
Lightrun is a Developer Observability Platform, allowing developers to add telemetry to live applications in real-time, on-demand, and right from the IDE.
- Instantly add logs to, set metrics in, and take snapshots of live applications
- Insights delivered straight to your IDE or CLI
- Works where you do: dev, QA, staging, CI/CD, and production
The most common issues for AWS – AWS SAM CLI are:
sam build does not recognise local nodejs projects outside CodeUri
sam build command is used to build the source code for an AWS Serverless Application Model (SAM) application. By default,
sam build will only look for source code within the
CodeUri property of the SAM template. If you have local node.js projects that are located outside of the
sam build will not be able to find them.
There are a few ways you can work around this issue:
- You can move your local node.js projects into the
CodeUridirectory, or a subdirectory of
CodeUri. This will allow
sam buildto find them and include them in the build process.
- You can use the
--base-dirflag to specify the base directory for the source code. This will allow you to build your SAM application from a different directory, which can include your local node.js projects.
- You can use the
--manifestflag to specify a list of files and directories that should be included in the build process. This will allow you to include your local node.js projects in the build, even if they are not located within the
For example, you could use the following command to build a SAM application that includes a local node.js project located outside of the
sam build --manifest "path/to/local/nodejs/project/**/*"
This will include all files and directories within the
path/to/local/nodejs/project directory in the build process.
Unable to build due to parent relative path
This error can occur if the source code for your application includes references to files or directories that are outside of the directory structure defined by the
CodeUri property in your SAM template.
Here are a few ways you can troubleshoot this issue:
- Check the source code for your application and look for any references to files or directories that are outside of the
CodeUridirectory. If you find any, try to modify the references so that they are relative to the
- Use the
--debugflag when running the
sam buildcommand. This will enable debug logging and may provide more information about the error you are encountering.
- If you are using the
--manifestflag to specify a list of files and directories to include in the build process, make sure that all of the paths are relative to the
- If you are using the
--base-dirflag to specify a different base directory for the source code, make sure that all of the paths in your SAM template are relative to the base directory you have specified.
More issues from AWS repos
Troubleshooting aws-aws-sdk-js | Troubleshooting aws-sdk-java-v2 | Troubleshooting aws-aws-toolkit-vs-code | Troubleshooting aws-aws-cdk
It’s Really not that Complicated.
You can actually understand what’s going on inside your live applications. It’s a registration form away.