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

Add Index arn in DynamoDB to sam yml file

I am trying access my DynamoDB via a user that has all access to the table. However I am failing to query the LSI for the same table. It says user doesn't have permissions to query index. I checked the documentation and it shows that index needs to…
0
votes
3 answers

sam build --use-container failed mounting directory

There was no issue in building the project a little while back, but it started throwing below error. RuntimeError: Container does not exist. Cannot get logs for this container Normally this happens when docker cannot mount the shared directory,…
Jimson James
  • 2,937
  • 6
  • 43
  • 78
0
votes
1 answer

Calling lambda recursively in sam local invoke

How can I recursively call lambda inside itself in sam local environment? const AWS = require('aws-sdk'); const lambda = new AWS.Lambda(); exports.foo = async(event, context) => { // ....... lambda.invoke({ FuncitonName: context.functionName,…
yskkin
  • 854
  • 7
  • 24
0
votes
0 answers

How can I organize my files in a project with AWS SAM (Microservices, nodejs)?

I need to have an API with the follow stack: AWS SAM & node.js with 2 microservices: users books What I did: sam init AWS Quick Start Templates nodejs12.x Name the project as books Now I have the following template: AWSTemplateFormatVersion:…
gsa
  • 24
  • 4
0
votes
2 answers

Reference local code in SAM using CfnFunction in the CDK with Python

I'm using the AWS CDK to create a SAM CfnFunction. For the codeUri property, it needs to reference a S3LocationProperty. When using the SAM CLI, I can do something like this Resources: HelloWorldFunction: Type: AWS::Serverless::Function …
maafk
  • 6,176
  • 5
  • 35
  • 58
0
votes
1 answer

AWS Cloudformation: "Invalid permissions on Lambda function" What's wrong?

I'm trying to invoke the lambda ReplySms through the Api Gateway Trigger This is my template.yaml: Resources: SmsRole: Type: AWS::IAM::Role Properties: RoleName: !Sub ${Environment}-${Application}-role …
0
votes
1 answer

Protect SAM defined API with WAF

How would one go about attaching a WAF to a SAM template defined API Gateway? Is there a way to specigy the WAF's ARN in the template?
titel
  • 3,454
  • 9
  • 45
  • 54
0
votes
2 answers

Deploying AWS Lambda using AWS SAM in Jenkins

Background : In our project we are doing bulk deployment in that we are having around 10 AWS Lambda functions, Few Scala applications and few configuration files. Currently we are deploying 10 lambdas if there is no change as well. Problem : Lets…
RakeshKalwa
  • 671
  • 2
  • 6
  • 16
0
votes
1 answer

Wrong IAM Policy generated by AWS SAM template

I am trying to build a AWS lambda based application with AWS SAM. while deployment, I have noticed that one of the IAM Policy created for lambda has wrong ARN. As you can see below(It is malformed): { "Statement": [ { …
0
votes
2 answers

AWS SAM fails to build layer

I have read that SAM now supports building layers and followed the directions mentioned here. However, i am getting a build error when i try to build the layer locally with sam build samDeployLayer Build Failed Error: NodejsNpmBuilder:NpmPack - NPM…
akurudi
  • 25
  • 5
0
votes
1 answer

AWS SAM/AWS Toolkit Docker Mounting Error

What path do I add to docker to enable AWS SAM to locally debug? Adding the path to the directory in which I work normally does not work.
Gunty
  • 1,841
  • 1
  • 15
  • 27
0
votes
3 answers

How to manage AWS Secret Keys for local development

I'm writing a lambda function in Python 3.8. The function connects with a dynamodb using boto3: db = boto3.resource('dynamodb', region_name='foo', aws_access_key_id='foo', aws_secret_access_key='foo') That is what I have while I am developing on my…
hkjhadj1
  • 848
  • 3
  • 13
  • 32
0
votes
1 answer

AWS::Serverless::Function lambda version for Lambda@Edge event handler

I am trying to use the AWS SAM framework to create a lambda to be used as a CloudFront event handler. It seems like the AWS::Serverless::Function doesn't support the Version attribute. The error I am…
tom
  • 1,331
  • 1
  • 15
  • 28
0
votes
2 answers

Enabling cors on a method in the template.yaml with the implicit API

I'm trying to enable Cors for the Stack RestAPI and all its methods whenever I deploy. I've managed to do it manually by creating an Empty Model, and then setting it up as the response alongst with statusCode 200. Problem is, I don't want it to get…
J. Doe
  • 13
  • 5
0
votes
1 answer

How to link a docker container with a node.js server

The command sam local start-lambda spins up a server inside a Docker container that emulates an AWS Lambda function: $ sam local start-lambda Starting the Local Lambda Service. You can now invoke your Lambda Functions defined in your template…
Maria Ines Parnisari
  • 16,584
  • 9
  • 85
  • 130