Questions tagged [aws-sam]

AWS Serverless Application Model (AWS-SAM) is an open source framework used to define, test and deploy serverless applications to the AWS Cloud.

From the Developer Guide:

Benefits of Using AWS SAM

Because AWS SAM integrates with other AWS services, creating serverless applications with AWS SAM provides the following benefits:

Single-deployment configuration

. AWS SAM makes it easy to organize related components and resources, and operate on a single stack. You can use AWS SAM to share configuration (such as memory and timeouts) between resources, and deploy all related resources together as a single, versioned entity.

Extension of AWS CloudFormation.

Because AWS SAM is an extension of AWS CloudFormation, you get the reliable deployment capabilities of AWS CloudFormation. You can define resources by using AWS CloudFormation in your AWS SAM template. Also, you can use the full suite of resources, intrinsic functions, and other template features that are available in AWS CloudFormation.

Built-in best practices.

You can use AWS SAM to define and deploy your infrastructure as config. This makes it possible for you to use and enforce best practices such as code reviews. Also, with a few lines of configuration, you can enable safe deployments through CodeDeploy, and can enable tracing by using AWS X-Ray.

Local debugging and testing.

The AWS SAM CLI lets you locally build, test, and debug serverless applications that are defined by AWS SAM templates. The CLI provides a Lambda-like execution environment locally. It helps you catch issues upfront by providing parity with the actual Lambda execution environment. To step through and debug your code to understand what the code is doing, you can use AWS SAM with AWS toolkits like the AWS Toolkit for JetBrains, AWS Toolkit for PyCharm, AWS Toolkit for IntelliJ, and AWS Toolkit for Visual Studio Code. This tightens the feedback loop by making it possible for you to find and troubleshoot issues that you might run into in the cloud.

Deep integration with development tools.

You can use AWS SAM with a suite of AWS tools for building serverless applications. You can discover new applications in the AWS Serverless Application Repository. For authoring, testing, and debugging AWS SAM–based serverless applications, you can use the AWS Cloud9 IDE. To build a deployment pipeline for your serverless applications, you can use CodeBuild, CodeDeploy, and CodePipeline. You can also use AWS CodeStar to get started with a project structure, code repository, and a CI/CD pipeline that's automatically configured for you. To deploy your serverless application, you can use the Jenkins plugin. You can use the Stackery.io toolkit to build production-ready applications.

1001 questions
4
votes
5 answers

Sam build fails with: Build Failed Error: NodejsNpmBuilder:NpmPack - NPM Failed: npm ERR! code Z_DATA_ERROR

I'm learning how to create lambdas on aws. I'm following this official tutorial. The commands I run: sam init (default values for everything, I'm choosing template 8 - webapp backend) cd sam-app sam build The output I'm getting is: Building codeuri:…
aurelia
  • 493
  • 8
  • 12
4
votes
3 answers

Stop AWS lambda event source from pushing events if downstream service is down

Is there a way to dynamically stop consuming events, when using aws lambda's built-in event source mapping? In the example diagram I would rely on the Big Service's healthceck to make that decision. So far I know that if Big Service is down, I could…
4
votes
3 answers

How to update existing lambda function using AWS SAM

I have some lambda functions that have been created before moving to AWS SAM. I would like to update my existing lambda function using AWS SAM. What would be the process of referencing the lambda function in AWS SAM. I have a lambda function already…
4
votes
2 answers

SAM app works but running pytest throws...ModuleNotFoundError: No module named 'aurora'

I've resisted writing this post for over a day because I was determined to find a solution from one of the many posts out there with answers to similar issues but none of them seem to work. My issue... When I run sam build && sam local invoke, it…
hugo
  • 1,175
  • 1
  • 11
  • 25
4
votes
3 answers

AWS SAM CLI Unit testing Lambda Functions NodeJS

I am using the SAM CLI to test and deploy AWS Lambda functions. I am trying to run unit tests using Mocha and Chai in NodeJS. The tests are located in the test directory and I can run the tests using the command mocha --recursive. The problem is I…
WK123
  • 620
  • 7
  • 18
4
votes
1 answer

How to Reference the Output of One Nested SAM Application from Another Application

I have an AWS SAM template that defines an application that references several other nested applications. I need to pass the Output of one nested application to the Parameter of another nested application, but I'm not sure of the correct…
Avalanchis
  • 4,500
  • 3
  • 39
  • 48
4
votes
1 answer

How to change AWS API Gateway default responses with SAM template?

I have an API with AWS API Gateway and Go Lambda functions. I have an issue, each time when i deploy new version of SAM it Overwrite Gateway responses on API Gateway. I tried to put it in SAM template but it seems it does not work or I'm not doing…
4
votes
1 answer

AWS SAM starting local api returns "Function name is required" error

We are using CDK to build our infrastructure configuration. Moreover, I create my template.yml for SAM with cdk synth --no-staging > template.yml if it helps. I am using AWS Toolkit to invoke/debug my lambda functions on Intellij which…
quartaela
  • 2,579
  • 16
  • 63
  • 99
4
votes
0 answers

Sam not encoding request body while being locally invoked

The event body is not getting encoded while invoking sam local start-api and sending a multipart request but it's being encoded in the cloud. So, I'd like to have the same behavior in my local environment. Steps to reproduce the issue: Create the…
Juanchi Rios
  • 119
  • 6
4
votes
1 answer

How to avoid AWS SAM rebuild and reupload a gradle function with unchanged code?

I'm developing an application with micronaut using SAM CLI to deploy it on AWS Lambda. As I was including dependencies and developing new features, the function packages got bigger an bigger (now they are around 250MB). This makes deployment take a…
ylima
  • 410
  • 5
  • 17
4
votes
2 answers

Building AWS Lambda layers with custom python functions using SAM

I am trying to build my lambda function using SAM. My lambda function depends on a custom python function which I plan to build as an AWS Lambda layer. My custom python function has a transitive dependency on a python package publicly available on…
4
votes
4 answers

How to add a resource based policy to a lambda using AWS SAM

I want to create a deployment script for some lambda functions using AWS SAM. Two of those functions will be deployed into one account(account A) but will be triggered by an s3 bucket object creation event in a second account(account B). From what I…
4
votes
1 answer

SAM build in container with environment variables

Is there a way to pass environment variables to the container doing the build in: sam build --use-container In the sam build documentation, in parameters related to Docker, there is only --docker-network and --skip-pull-image Use case: I am using…
forzagreen
  • 2,509
  • 30
  • 38
4
votes
1 answer

AWS SAM template doesn't execute BuildMethod

I have a lambda functions that has somewhat non standard packaging. I am using a Makefile to help me package what I need and use it as my build method with sam build command. However I don't see this makefile being executed. Can't figure out why…
HIT_girl
  • 785
  • 7
  • 23
4
votes
0 answers

Including local source code directories and files in aws-sam?

I work in a mono repo where I have a AWS SAM (lambda) application. The structure is more or less like so: . ├── my_folder1   ├── file1.py   ├── __init__.py    └── file2.py    ├── my_folder2    │   └── my_folder3    │   ├── __init__.py …