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
7
votes
2 answers

API Gateway HTTP Proxy integration with aws-sam (NOT Lambda Proxy)

I am trying to use aws-sam to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this: All of the aws-sam examples which I've found, as well as related…
Daniel B.
  • 1,650
  • 1
  • 19
  • 40
7
votes
1 answer

Create an API Gateway Proxy Resource using SAM

I have an apparently-simple requirement to create a proxy resource in SAM (Amazon's Serverless Application Model). So simple in fact that Amazon's documentation appears to leave this as an exercise to the reader! I want to create an AWS API Gateway…
7
votes
0 answers

AWS SAM- Can we deploy code for a single function without deploying the whole stack?

I am new to Serverless and AWS SAM. I have tried creating a template.yaml for my new lambda functions and api gateway's of my application and deployed to AWS using AWS SAM. It worked fine. But my question is for every deploy, we got to create new…
merla
  • 489
  • 1
  • 5
  • 12
7
votes
2 answers

SAM Serverless implicit API vs AWS::Serverless::Api

When configuring a SAM template and defining a AWS::Serverless::Function there is the Events param that accepts an Api type. Does this create an API Gateway resource? What is the difference between this event type and a standalone…
TemporaryFix
  • 2,008
  • 3
  • 30
  • 54
7
votes
2 answers

AWS SAM CLI java8 runtime is not supported

I'm trying to build a Lambda application using AWS SAM CLI command: sam build --template C:/MyProject/template.yaml --build-dir C:/MyProject/.aws-sam/build but I'm getting this error: Build Failed Error: 'java8' runtime is not supported This is…
Michael Dz
  • 3,655
  • 8
  • 40
  • 74
7
votes
2 answers

Setting environmental variables with !Ref in AWS SAM?

I'm using SAM CLI v0.8.1. I'm trying to set environmental variable MY_TABLE_VAR as name of the table in my resources (MyTableResource). However, while running my app locally, the MY_TABLE_VAR is undefined. Can you tell me what's wrong in my template…
Mahdi
  • 1,089
  • 1
  • 14
  • 27
7
votes
2 answers

AWS SAM - 'Encountered unsupported property CodeUri' error when deploying packaged template

After migrating a CloudFormation template to AWS SAM approach, when deploying template created with aws cloudformation package, in CloudFormation I get error Encountered unsupported property CodeUri on all Lambda functions that are included in the…
Lech Migdal
  • 3,828
  • 5
  • 36
  • 63
6
votes
5 answers

AWS SAM - Esbuild Failed: cannot find esbuild

I'm trying out AWS SAM with nodeJS and Typescript using 'sam init', but when I want to build the example hello-world-typescript application using 'sam build', I get the following message: Building codeuri: C:\RF\GitHub\rf-09-06\hello-world runtime:…
Toba
  • 61
  • 1
  • 3
6
votes
1 answer

cannot import name 'BaseRequest'

I am building a flask lambda application using AWS SAM and my requirements.txt file looks like follows requests contentful flask-lambda numpy Recently the flask lambda libraries were updated and since then i am getting the following error whenever i…
6
votes
0 answers

Golang AWS SAM lambda Function debugging is not working on M1 Mac

When trying to debug simple SAM, I'm receiving the following error: could not launch process: fork/exec /var/task/hello: function not implemented Is anyone knows how to solve it? The full log is: Mounting /Users/.../HelloWorld as…
omer blechman
  • 277
  • 2
  • 16
6
votes
1 answer

404 error while adding lambda trigger in cognito user pool

I have created a SAM template with a function in it. After deploying SAM the lambda function gets added and are also displayed while adding lambda function trigger in cognito but when I save it gives a 404 error. SAM…
Himanshu Patil
  • 536
  • 1
  • 6
  • 18
6
votes
3 answers

SAM Template - define HttpApi with Lambda Authorizer and Simple Response

Description of the problem I have created a Lambda function with API Gateway in SAM, then deployed it and it was working as expected. In API Gateway I used HttpApi not REST API. Then, I wanted to add a Lambda authorizer with Simple Response. So, I…
mastazi
  • 1,623
  • 26
  • 41
6
votes
1 answer

How to run multiple lambda functions when deploying as a Docker image?

How does the dockerfile look like for aws lambda with docker image via aws-sam when declaring multiple functions/apps in templates.yaml? Here is the sample dockerfile to run "a single app" FROM public.ecr.aws/lambda/python:3.8 COPY app.py…
xtremeHitori
  • 63
  • 1
  • 5
6
votes
0 answers

How to publish a nested stack in AWS Serverless Application Repository

I've used sam package to package my local file to s3. The resulting template looks like this: AWSTemplateFormatVersion: "2010-09-09" Transform: AWS::Serverless-2016-10-31 Metadata: AWS::ServerlessRepo::Application: Name: test_nested_stack …
Mickael B.
  • 4,755
  • 4
  • 24
  • 48
6
votes
1 answer

Error on setting CORS header for API Gateway lambda authorizer

I have a lambda authorizer for my API Gateway authorization. When authorizer returns 401 or 403 I do not get CORS back in response header. I am using AWS::Serverless::Api resource, and after some research found here that I need to set…
0bj3ct
  • 1,400
  • 4
  • 22
  • 51