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

How do you make AWS SAM deploy use aws profile?

I need to have SAM deploy use a specific aws config profile. Where do you set that? This aws profile assumes a role needed for deploying.
Andy N
  • 1,013
  • 9
  • 25
5
votes
0 answers

api gateway rest api geolocation headers

I am using AWS SAM CLI According to https://aws.amazon.com/about-aws/whats-new/2020/07/cloudfront-geolocation-headers/ geolocation is already supported and CloudFront returns with the geolocation headers; example: CloudFront-Viewer-Country-Name:…
5
votes
1 answer

How do I see the full logs of a local invocation of a Lambda via SAM?

I am using the default HelloWorld example My code is: let response; exports.lambdaHandler = async (event, context) => { console.log(event); try { response = { 'statusCode': 200, 'body': JSON.stringify({ …
Itay Moav -Malimovka
  • 52,579
  • 61
  • 190
  • 278
5
votes
1 answer

AWS SAM - Attach an already existing API gateway as a trigger to a lambda

I have a lambda that is created by deploying an AWS SAM stack. Now I have mentioned in the Events section that the lambda is to be triggered by an API, but the issue being that this creates a new API, instead of re-using the existing one in the…
Mooncrater
  • 4,146
  • 4
  • 33
  • 62
5
votes
1 answer

Timeout while waiting for command: "sam local invoke"

I'm building server less applications using AWS SAM SAM + VSCode + Docker desktop Everything was working fine, but suddenly I started getting timeout error when I run debug. Note: sam local invoke (without debug) works fine. Problem occurs when i…
5
votes
2 answers

Pythonpipbuilder: resolve dependencies - list index out of range

Description: I am trying to use sam build with the following requirements but its throwing the error: Pythonpipbuilder: resolve dependencies - list index out of range pyotp ulid-py aws_encryption_sdk boto3 requests attrs cryptography Steps to…
Pablo Arriola
  • 334
  • 3
  • 15
5
votes
1 answer

How to add custom names Lambda function, API gateway, and Stage name in SAM template

I am trying my hands on SAM templates. Here I am trying to figure out how can I add custom names within the template. As when I package and Deploy the Template it creates the lambda function with an added alphanumeric value. API gateway name will be…
sumanth shetty
  • 1,851
  • 5
  • 24
  • 57
5
votes
3 answers

AWS SAM & Parameter Store: How to select parameter for the deployment into different environments

I have a setup where I am using CodeCommit as my repository to store lambda functions and CodePipeline using AWS SAM to deploy and create lambda functions. I would like to deploy the lambda functions into different environments such as QA, staging,…
5
votes
3 answers

Python is not configured for aws sam cli

I am following this tutorial to build a SAM App: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-getting-started-hello-world.html When i did sam build, I got following error ❯ sam build Building codeuri:…
Em Ae
  • 8,167
  • 27
  • 95
  • 162
5
votes
4 answers

How do you deploy cloudformation with a lambda function without inline code?

the lambda function size is over 4096 characters, so I can't deploy lambda function as inline codes in cloudformation template. (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html) ZipFile Your…
5
votes
1 answer

Adding lambda integration to HttpApi routes with SAM

I am currently attempting to have a AWS::Serverless::HttpApi integrate with a group of AWS::Serverless::Function's. The goal is to define these resources within a SAM template, and define the actual API using a swagger file. I have my SAM template…
Chris
  • 185
  • 1
  • 14
5
votes
0 answers

How to use SAM deploy to get a lambda, with AutoPublishAlias AND additional alises

My goal here is that additional SAM deploy calls will result in the :staging alias reflecting the latest version and :live will get updated by outside means, but has to be initialized to the same version created at deploy-time. I'm using SAM deploy…
rainabba
  • 3,804
  • 35
  • 35
5
votes
1 answer

Can I include a test event in a SAM template that is deployed to the lambda web console?

I know I can invoke lambdas with sam local and also the command line. But sometimes it's convenient to test the lambda by invoking it through the UI by configuring a test event there. Is it possible to include sample/test event in the sam template…
red888
  • 27,709
  • 55
  • 204
  • 392
5
votes
1 answer

Use /path/{proxy+} with AWS SAM to have a greedy API in API Gateway

I'm using SAM. The following setup works: Function: Type: AWS::Serverless::Function Properties: CodeUri: ./code/ Runtime: go1.x MemorySize: 64 Handler: main Events: TesstApi: Type: Api …
mealesbia
  • 845
  • 2
  • 12
  • 28
5
votes
1 answer

How to add Tags to Private API Gateways in AWS SAM

I have created an API Gateway using AWS::Serverless::API in SAM and now I want to add Tags to Gateway in order to enforce security constraints on every Gateway with the same tag. Type: AWS::Serverless::Api Properties: Name: PrivateApi …
VoltreX
  • 301
  • 1
  • 8