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

AWS SAM YAML template - Unknown Tag !Ref

When I try to deploy my AWS SAM YAML file, it fails saying the !Ref is an unknown tag. Any ideas to get around this? AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: MySimpleFunction: Type:…
EdsonF
  • 2,719
  • 3
  • 30
  • 34
35
votes
6 answers

Nested Step Function in a Step Function: Unknown Error: "...not authorized to create managed-rule"

I have a Step Function (Parent) created in a SAM/CloudFormation template that, among other things, calls another Step Function (Child). I'm following the instructions on calling Child, from Parent, using the service integration pattern. But I'm…
27
votes
3 answers

AWS SAM - Failed to create the changeset: Waiter ChangeSetCreateComplete failed

AWS SAM deploying codebase to AWS cloud using aws-sam-cli but it throw me below error. Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Requires capabilities :…
Sagar
  • 4,473
  • 3
  • 32
  • 37
22
votes
4 answers

How do I connect to host MySQL from AWS SAM local docker instance?

I am trying to invoke my Lambda function using sam local invoke but find that it cannot connect to my host MySQL. I tried adding --docker-network host but it also cannot connect Traceback (most recent call last): File…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
21
votes
2 answers

What's the difference between AWS sam build and sam package when using SAM?

I'm building some serverless apps and trying to use SAM. I've been going through some tutorials and some use sam build, while others use sam package. What are the differences between these commands? It seems like sam package is more difficult to…
20
votes
1 answer

How to deploy to different environments with AWS SAM

I have two questions about AWS SAM and deployments. I’m reading through the docs and checking through examples like this and I’m still not quite sure how to deploy to a staging and production environment separately with my SAM template. Is it as…
Petesta
  • 1,623
  • 3
  • 19
  • 29
19
votes
1 answer

Using Amplify and SAM together?

I'm having some confusion here and wanted to see if someone can set me straight. I'm using Amplify for a Vue app. It calls API Gateway which calls Lambda and all of this is set up manually but I want to use the power of IaaS and do it with…
17
votes
5 answers

Referencing !Ref DynamoDB table name in a AWS CloudFormation template

I am trying to locally test passing the table name of a DynamoDB table as declared in my CloudFormation template file. From all the documentation I have read, I should be able to reference the the TableName property value of a DynamoDB resource…
McShaman
  • 3,627
  • 8
  • 33
  • 46
16
votes
2 answers

AWS Lambda in Python: Import parent package/directory in Lambda function handler

I have a directory structure like the following in my serverless application(simplest app to avoid clutter) which I created using AWS SAM with Python 3.8 as the runtime: ├── common │   └── a.py ├── hello_world │   ├── __init__.py │   ├── app.py │  …
Syed Waqas
  • 2,576
  • 4
  • 29
  • 36
15
votes
3 answers

How to unit test lambda logic which uses layer methods?

Hi I have my AWS Lambda and I wanted to add a layer to it. I would like to be able to just test single methods of lambda. However many of them use layer logic and because of that it doesn't seem to me to be easy. What is the best approach to do this…
Clyde Barrow
  • 1,924
  • 8
  • 30
  • 60
14
votes
3 answers

Why Lambda@Edge has to be in us-east-1 region?

I am trying to create a CloudFormation stack in us-east-2 (Ohio) region. However, getting the following error com.amazonaws.services.cloudfront.model.InvalidLambdaFunctionAssociationException: The function must be in region 'us-east-1' I have gone…
cmxiv 914
  • 610
  • 6
  • 10
14
votes
3 answers

SAM Local doesn't appear to be running Authorizer functions

I've just gotten started using SAM Local, but am coming up againast an issue when trying to configure an Authorizer function for my endpoints. I've been looking at the main SAM documentation for how to set up the Auth functions, but whenever I try…
cchapman
  • 3,269
  • 10
  • 50
  • 68
13
votes
4 answers

AWS SAM CLI Fresh install throws error - dyld: Library not loaded: @executable_path/../.Python

I am trying to use the AWS SAM CLI installed through Homebrew and I am seeing the following error when I try to use sam with any command: dyld: Library not loaded: @executable_path/../.Python Referenced from:…
RobertoCuba
  • 881
  • 9
  • 25
12
votes
1 answer

Specify multiple API stages and Lambda Aliases in SAM template defining a single AWS::Serverless::Function

What I am aiming for I'm trying to write a (single) SAM template for obtaining a Lambda function triggered by Api Gateway events. I want to have multiple API Stages (say "dev", "testing", "prod") and I want each of them to be mapped onto a Lambda…
12
votes
1 answer

AWS SAM Local Lambda invocations slow

I'm trying to test my lambda functions locally using the SAM local CLI. I start the API with this command: sam local start-api --template ./sam-template.yml --host 0.0.0.0 --port 4001 However, every time I call the API the lambda invocation takes a…
alayor
  • 4,537
  • 6
  • 27
  • 47
1
2 3
66 67