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

Does SAM Lambda auto-versioning using AutoPublishAlias work when code URL changes but the code that it points to doesn't?

Simple question: Does SAM Lambda auto-versioning using AutoPublishAlias work for AWS::Serverless::Function when code CodeUri changes but the actual code that it points to doesn't? Background We are deploying several Lambda@Edge functions using the…
4
votes
1 answer

How to enable "ApiKeyRequired" property in SAM without explicit swagger definition?

In cloudformation, AWS::ApiGateway::Method has a boolean property ApiKeyRequired . How can i achieve the same in SAM ? I know that we can enable using explicit swagger Configuration. which is like this { "swagger": "2.0", "info": { …
Private
  • 1,661
  • 1
  • 20
  • 51
4
votes
2 answers

Dynamic AWS Sam Schedule Event Input param

We are automating a lambda via SAM to run on a Schedule Event. We use YAML but we are unable to work out how to use !Sub to make the Input be dynamic. If you read the sam documentation it says that Input needs to be a JSON formatted string The…
4
votes
2 answers

Deploy AWS SAM functions using already created roles

When trying to deploy to AWS using AWS SAM CLI my Lambda functions using the following script: aws cloudformation deploy --template-file /Users/ndelvalle/Projects/foo/functions/packaged-template.yaml --stack-name foo --region sa-east-1…
Nicolas Del Valle
  • 1,384
  • 15
  • 20
4
votes
2 answers

Contract Testing for AWS Lambdas

Is there any way to do Contract testing for the AWS lambdas. Pact is being used for normal APIs, But I am trying to implement Contract Testing on AWS SAM. Is there any tool for this or Pact can be used with any modifications?
user3602058
  • 219
  • 4
  • 10
4
votes
1 answer

sam local start-lambda - how to send send s3 event to sam local endpoint

I can invoke a local lambda http endpoint (sam local start-lambda), but how do I trigger that lambda endpoint with a (mock) AWS event (s3, etc.) like I can when using the Dockerized lambda environment (sam local invoke -e event.json…
tedro
  • 51
  • 1
  • 5
3
votes
1 answer

AWS Toolkit vscode extension, Connect Using AWS Identity Center keeps trying to access the wrong region

I installed the extension AWS Toolkit for VScode. My IAM Identity Center Users, Groups, etc were all created in us-east-2. But for some reason AWS keeps trying to route me through us-east-1 even though this causes an invalid_grant Invalid grant…
ChristianOConnor
  • 820
  • 7
  • 29
3
votes
1 answer

Controlling SAM function log-group creation

When using CloudFormation with SAM, and creating a SAM function - a log group for that lambda may or may not be created. The existence of the log group when the SAM function resources have entered the CREATE_COMPLETE state depends on the…
Shlomi Borovitz
  • 1,700
  • 9
  • 9
3
votes
0 answers

AWS SAM lambda container: when specifying resolve-image-repos, what should ImageUri be?

I'm trying to deploy a docker image as a lambda function via AWS SAM. My SAM template looks something like: Resources: StrapiFunction: Type: AWS::Serverless::Function Properties: PackageType: Image Events: Strapi: …
Wintermute
  • 2,973
  • 4
  • 32
  • 52
3
votes
2 answers

AWS API Gateway - CORS error despite following tutorial

I have a sam file trying to build an API Gateway to a lambda function. I am following the latest AWS documentation for configuring cors. This documentation is quoted here: As you may have guessed, that isn't working for me. If I use…
3
votes
1 answer

What is the difference between PackageType: Image and build --use-container in a SAM App?

PackageType: image seems to require a Dockerfile (looking at the hello-world example) along with ImageUri and Metadata And it also doesn't want me to use Runtime, Handler, Layers (not even using layers) whereas build --use-container does not seem to…
3
votes
2 answers

samconfig.toml - What is the meaning of version?

What is the meaning of version=0.1 (or indeed, version=x.x for some other version) at the top of the AWS SAM CLI configuration file? I've looked through a couple of AWS docs and can't seem to find an explanation for what the version means/does:…
Colm Bhandal
  • 3,343
  • 2
  • 18
  • 29
3
votes
0 answers

aws-sam local tmp directory

I'm working on some functions to generate documents and email them off, that all works but it's hard to debug waiting for the email. I write the file to the lambda tmp folder, and I can see it there by listing the directory in my code, but I can't…
Bob Bryden
  • 51
  • 2
3
votes
0 answers

Debugging AWS SAM in VSCode - Don't stop debugger at wrapper entry file

I've created a AWS SAM project using nodejs14.x. I've been able to get debugging working, but every time I run my program it stops on an AWS wrapper index.js file. See this link for a picture of the actual file. It looks like the file is located at…
3
votes
1 answer

APIGateway returns `Internal server error` despite adding resource based permissions for Lambda

I built a simple HelloWorld API using a lambda function and APIGateway. I'm using Cloudformation. The lambda function runs fine when I run it using aws lambda invoke. The API runs locally using sam local start-api. But when I deploy it using sam…