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
12
votes
3 answers

How to transform a Serverless Application Model (SAM) template to Cloudformation?

From this answer I understand that SAM is a transform of Cloudformation. Is there a way to get the transformed Cloudformation template from a SAM template via the console, CLI, or another way?
12
votes
1 answer

AWS SAM : Nested Stacks, Referring to API gateway from the Root stack

I want to split my SAM application into multiple parts. I want to create a API ( AWS::Serverless::Api ) in the root stack. I am creating lambda functions in my child stacks, where I want to give the reference of the API from the root stack to the…
11
votes
6 answers

How to enable CORS with AWS SAM

I'm trying to enable CORS in my AWS SAM app. Here is the snippet from my template.yaml: Globals: Api: Cors: AllowMethods: "'*'" AllowHeaders: "'*'" AllowOrigin: "'*'" Resources: MyApi: Type: AWS::Serverless::Api …
11
votes
1 answer

How to store and use HTML templates in serverless application on AWS Lambda (using AWS SAM)?

Instead of (A) following a more traditional route for running a web application on AWS (e.g., using Ruby/Sinatra or Python/Flask on AWS EC2 or Beanstalk), or (C) creating static HTML and JavaScript files in S3 and dynamic API endpoints in AWS…
Jochem Schulenklopper
  • 6,452
  • 4
  • 44
  • 62
10
votes
2 answers

Why does sam build command display warning "ServerlessRestApi" is a reservered logical ID?

I created the sample app with sam init. When I the run sam build, I get the warning: Your template contains a resource with logical ID "ServerlessRestApi", which is a reserved logical ID in AWS SAM. It could result in unexpected behaviors and is not…
Matthew MacFarland
  • 2,413
  • 3
  • 26
  • 34
10
votes
1 answer

Where does the console.log output go when I deploy aws lambda locally?

If I use aws lambda on the cloud, console.log output is routed to cloudwatch. But where does it go if I use sam local start-api? Because I can't find it in cloudwatch
user2741831
  • 2,120
  • 2
  • 22
  • 43
10
votes
0 answers

What's the correct way to structure a large API Gateway using AWS SAM nested applications?

I have an API with around 150 endpoints. When I try to deploy the whole thing in one SAM (Serverless Application Model) template it fails (expected) because the 744 resources it wants to create is greater than the maximum allowed 200. I broke the…
Fo.
  • 3,752
  • 7
  • 28
  • 44
10
votes
1 answer

How to get stack output from AWS SAM?

I would like to perform automatic integration tests on my serverless projects. To do that, I need to get the api endpoints somehow. There is already the plugin serverless-stack-output for Serverless framework that serves the purpose. But I'm…
Mahdi
  • 1,089
  • 1
  • 14
  • 27
9
votes
4 answers

AWS SAM deployed Error under hello world template

I'm currently working on AWS serverless lambda function deployment and try to distribute and test with AWS SAM. However, when I followed the AWS SAM hello world template tutorial on official website, I can't really deploy my code to AWS. I've…
9
votes
2 answers

how to include multiple resource files in SAM template.yml

I want to write my cloud formation yml file in a different file and load them separately. It is easy to do it in the serverless framework but I couldn't figure it out how to do it with SAM. Would you mind help me how to do it? I provided a copy of…
Amir
  • 1,919
  • 8
  • 53
  • 105
9
votes
6 answers

SAM Build only completes successfully with --use-container parameter

I'm developing a Lambda function written in python3.6 to test locally, then deploy to AWS once working. I'm using PyCharm's AWS Serverless Toolkit for this. SAM build is not building successfully when not including the --use-container…
OscarVanL
  • 701
  • 1
  • 6
  • 21
9
votes
4 answers

Function not found after manually deleting a function in a SAM CloudFormation stack

I am using sam deploy to deploy lambda function and API gateway. It works fine but it doesn't work after I manually deleted the lambda function via AWS console. I got below error: "ResourceStatusReason": "Function not found: …
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
9
votes
1 answer

Multiple Lambda functions from the sam.yml file

Still waiting for actual AWS support for this: https://github.com/aws-samples/aws-serverless-samfarm/issues/5 How is this supposed to work? My use case is I have an API Gateway fronted lambda that writes events to an SNS topic. I have another lambda…
red888
  • 27,709
  • 55
  • 204
  • 392
8
votes
4 answers

Using AWS SAM-CLI requires rebuild every time I update the code

I am using SAM CLI to develop an API Gateway Lambda proxy integration. According to the docs, I should be able to use sam local start-api to test my endpoint locally. The start-api command allows for "hot reloading" as described in the AWS SAM…
Jeff
  • 2,293
  • 4
  • 26
  • 43
8
votes
4 answers

AWS SAM - Config TOML File

Working through a deployment on a stack using AWS SAM and deploying via GitHub actions and was trying to use the Config TOML file and specifying a config environment in the deploy command and I am running into the issue where it seems to be just…
OMeThEre
  • 81
  • 1
  • 1
  • 2
1
2
3
66 67