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

How to pass AWS SAM deploy a list of capablities?

I'm trying to pass multiple capabilities to sam deploy sam deploy --guided --capabilities "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND" I have tried different forms of this, essentially encoding the list as an array with "[CAPABILITY_IAM,…
Josh Russo
  • 3,080
  • 2
  • 41
  • 62
6
votes
2 answers

Manage stage and prod environments in AWS SAM/Cloudformation template along with CI/CD support

I'm having an AWS SAM template file with some resources hosted on github, a codepipeline has been setted up to detect changes in the repo then create/update and execute changes on cloudformation stack. Everything is working fine. But now I need to…
6
votes
0 answers

AWS API Gateway changes OAS3 path and query parameter types to string

When creating an API Gateway using an OAS3 definition, the path and query parameter types get changed to strings. I can't find any AWS documentation stating the expected behavior or why this is. I know when configuring the API Gateway manually it…
Nathanial
  • 2,177
  • 1
  • 15
  • 34
6
votes
1 answer

Add inline policy to aws SAM template

I'm using SAM Template to create my serverless application. Using the tag Policies under the properties of the resource I can add standard policies like this: Resources: QueryFunction: Type: AWS::Serverless::Function Properties: …
rivamarco
  • 719
  • 8
  • 23
6
votes
1 answer

Access files written into /tmp with aws sam local

I am working on a project using AWS SAM local. I am invoking a function with sam local invoke which successfully executes the function. The lambda function writes an image file into /tmp/image.png when the function is invoked. This writing operation…
tiivik
  • 91
  • 5
6
votes
1 answer

sam build is unable to locate the pom.xml file

I have a Maven Project which has a module 'AddUser'. This module is basically a sam application. When trying to run the command 'sam build' from the project root path. I am getting the below error:- in-iftekhar-04eb:UserPlanning iftekhar.khan$ sam…
Sunny
  • 858
  • 3
  • 17
  • 39
6
votes
4 answers

SAM API Gateway with Cloudformation WAFRegional

To secure our API, I'm trying to deploy a WAFRegional with a RateBasedRule. The API Gateway is located in a SAM template wherein I have also a nested stack for the child template holding the WAFRegional configurations. The child template for the…
MartinaW
  • 335
  • 3
  • 11
6
votes
1 answer

AWS API Gateway supports CORS for OPTIONS only when using SAM (without Lambda proxy integration)

I'm using AWS Serverless for building a small site with around 15 Lambda functions. My Cloudformation stack is completely built using SAM. I'm NOT using Lambda proxy integration. The Api section in the SAM yaml template config looks like…
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99
6
votes
0 answers

Posting image using form-data via API Gateway to Lambda function results in invalid file

I've a Lambda function written in Go that supposed to allow image file upload—via an HTML form/JavaScript and an API Gateway integration—into an S3 bucket, all defined in a SAM template. Here's an example of the Lambda function execution log: Now…
6
votes
3 answers

AWS SAM Template - Define SQS queue triggered by API Gateway

I'm facing a problem when trying to deploy my stack via AWS SAM CLI. I'm using the SAM simplified template which I package and deploy. All I want is to create an SQS queue and implicitly create an API Gateway that will just put the payload into the…
6
votes
2 answers

AWS CodePipeline, CodeDeploy, SAM and Lambda: how to (inter)connect those?

I'm a kind of lost in the documentation. I want to push Python code to a repo and use CodePipeline to deploy Lambdas. I have CodeCommit repo, CodePipeline - so far this works and I can create/update CF stack to create supplementary resources. I…
5
votes
0 answers

Test Go Lambda locally with AWS Serverless Application Model and localstack

I am trying to test locally a lambda function that is listing buckets on a S3 bucket. To have a local S3 bucket for my test, I use localstack: docker run --rm -it -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack I can then create a bucket…
Jérémy
  • 111
  • 6
5
votes
1 answer

What is the difference between path and resource (or resourcePath) in an AWS API-gateway AWS-proxy event?

I'm in the process of learning AWS Lambda. I have created a lambda that will act as a REST API (APIEvent in CloudFormation terms) and want to debug that Lambda locally using an event. If I understand correctly, running sam local generate-event…
DieterDP
  • 4,039
  • 2
  • 29
  • 38
5
votes
2 answers

How to create AWS resources to run a CDK application locally using SAM?

I have an application called Example4Be, I have a stack that creates the AWS non-Lambda resources (just DynamoDB in this case, but could be SQS, SNS, etc): import * as cdk from "aws-cdk-lib" import {Construct} from "constructs" import * as dynamodb…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
5
votes
1 answer

How to write Resource-based policy in Cloudformation

I want to invoke a Lambda from an external AWS account, and I managed to do it by creating a Policy statement in the Resource-based policy tab of the console (Lambda > Configuration > Permissions > Resource-based policy). Although, I cannot find a…
akai
  • 352
  • 1
  • 6
  • 16