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
5
votes
1 answer

How to define multiple triggers for lambda function in SAM template?

I created a lambda function from a SAM template, and defined multiple triggers, but only one of these triggers is being created in cloudformation. This is my sam template: Myfunc: Type: AWS::Serverless::Function Properties: …
David Perez
  • 478
  • 5
  • 17
5
votes
1 answer

aws sam package - unable to upload artifact, access denied when doing 'package' locally but the S3 bucket exists and I have access

I try to package but I get: $ sam package --s3-bucket sam-project-deployment--29 --output-template-file output.yaml --region us-east-2 Error: Unable to upload artifact HelloWorldFunction referenced by CodeUri parameter of HelloWorldFunction…
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
5
votes
3 answers

AWS Lambda's: SAM deployment ...identifying and removing old S3 package versions?

I'm relatively new to AWS lambda's and SAM, and now I've got things working I've got a seemingly simple question I can't find an answer to. I've spent the last week getting a lambda app up and running using SAM (build, package, deploy numerous times…
Richard
  • 3,024
  • 2
  • 17
  • 40
5
votes
4 answers

aws sam build not able to build packages which require paramiko due to "Error: PythonPipBuilder:ResolveDependencies"

I've been learning the ropes with AWS SAM and have successfully deployed a number of lambdas together with dependencies and other AWS services. However, I seem to have run into a problem when trying to deploy a lambda which relies on some specific…
user3062260
  • 1,584
  • 4
  • 25
  • 53
5
votes
1 answer

Is it possible to configure different API Gateway stages with different lambda versions using AWS SAM

I have a SAM template for my application. Each time I deploy my SAM template with a new API Gateway stage name, it replaces the previously created stage. So, found this article which helps me in releasing different versions pointing to different…
5
votes
1 answer

AWS SAM: The REST API doesn't contain any methods

I'm trying to use AWS SAM to deploy a simple API. When the API is simple (that is, does not specify explicitly an API Gateway). the deployment succeeds. However, the following deployment fails: AWSTemplateFormatVersion: '2010-09-09' Transform:…
5
votes
2 answers

How to connect RDS instance when running SAM locally?

I am using SAM (Serverless application model) to test Lambda functions locally that connect to an Aurora RDS instance in the cloud. Using the following command: sam local invoke "lambda function name" --event event.json The Lambda function is being…
Jignesh Patel
  • 61
  • 1
  • 4
5
votes
1 answer

Adding Parameters to Serverless.Template File

I am using Jenkins Pipeline to publish a Visual Studio AWS Serverless .Net Core Application. Can somebody tell me whether it is possible to add parameters to the serverless.template file? I would then be able to populate these parameters using the…
markc
  • 51
  • 2
4
votes
1 answer

How to include static files into the lambda package with AWS SAM esbuild?

I have a NodeJS AWS Lambda function which generates an e-mail based on a html template file (emailTemplate.html). I started building my lambdas with esbuild via SAM. Now I wonder how I can configure SAM/esbuild to include this file into my lambda…
Tim Van Laer
  • 2,434
  • 26
  • 30
4
votes
1 answer

Test lambda locally with curl

Normally, for testing lambda locally, I use sam local invoke WebhookFunction -e test.json in test.json {"body":"test"} This valiable is passed to event. def lambda_handler(event, context): Now I want to do equivalent thing by curl I tried…
whitebear
  • 11,200
  • 24
  • 114
  • 237
4
votes
1 answer

AWS SDK SAM VS Code debugger runs but why does it break on internal /var/runtime/index.js first?

It's debugging the wrong file when the debugger starts up. Using SAM CLI 1.40 and latest VS Code. I followed directions here: https://docs.aws.amazon.com/toolkit-for-vscode/latest/userguide/serverless-apps-run-debug-no-template.html Here's my…
Tsar Bomba
  • 1,047
  • 6
  • 29
  • 52
4
votes
0 answers

AWS sam is slow to deploy

When "sam deploy" runs it first checks one by one if each asset is in S3 (seems to be a bunch of HEAD requests). This is a very slow process in one of our projects that has grown to have maybe 30 lambdas and 50 appsync query/mutation VTL files in…
Ben
  • 495
  • 1
  • 7
  • 17
4
votes
0 answers

Create multiple API Gateway stages with different integrations

I'm trying to create a lambda function associate with an API Gateway. A new lambda version for that function will be created whenever new version is deployed, this version will have this ARN arn:lambda_arn:[version]. Also a new API Gateway stage…
Amer Sawan
  • 2,126
  • 1
  • 22
  • 40
4
votes
0 answers

Difference between AWS::Serverless::Api and AWS::Serverless::HttpApi

I'm having a hard time understanding the difference between AWS::Serverless::Api and AWS::Serverless::HttpApi. I was looking at this AWS repo for Api and HttpApi and wasn't able to understand why I'd use one over the other. I see there are different…
Petesta
  • 1,623
  • 3
  • 19
  • 29
4
votes
1 answer

AWS SAM - Apply policy template for a resource created conditionally

I create a DynamoDb table conditionally: MyDynamoTable: Type: AWS::DynamoDB::Table Condition: IsDevAccount and this is how IsDevAccount is defined using an input parameter: Conditions: IsDevAccount: !Equals [ !Ref Stage, dev ] Now I'm…
Amir Keibi
  • 1,991
  • 28
  • 45