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

Cannot access local MongoDB from sam local

I have Windows 10 machine where MongoDB is installed. I can connect it from a command line. I run NodeJS app with sam local. When I use a production environment, the app can access Mongo Atlas cloud instance. But when I switch to a dev environment…
Leos Literak
  • 8,805
  • 19
  • 81
  • 156
0
votes
0 answers

How to handle unit test with "large" test data of Nodejs AWS Lambda application

When we are developing our Node applications (which then run Serverless in production and locally via SAM) we would like to use Jest to unittest our application. We are now faced with the issue that our testdata is 'large' (thousand rows of JSON and…
Zanndorin
  • 360
  • 3
  • 15
0
votes
1 answer

How to get at the role created by cloudformation when creating a lambda

Here is my lambda definition in cloudformation: CommandTopic: Type: AWS::SNS::Topic Properties: DisplayName: 'ns-poc-commands' TopicName: 'ns-poc-commands' SendMessage: Type: AWS::Serverless::Function Properties: …
Michael Wiles
  • 20,902
  • 18
  • 71
  • 101
0
votes
1 answer

AWS Lambda / SAM: How to get invocation URI from CLI?

As part of a AWS SAM template, I have a function with an HttpPost event trigger. Because I'm using the AWS SAM transform, I am not explicitly declaring the API Gateway that gets created to route this http post to trigger the function. Given that, is…
Andrew Schwartz
  • 4,440
  • 3
  • 25
  • 58
0
votes
1 answer

IntegrationResponse SAM Template

Questions: IntegrationResponse to Sam template ? Is it possible without OpenApi? Way to add headers to GatewayResponses in SAM template? What im trying to achive: Define gateway responses and integration responses inside a SAM CloudFront…
0
votes
1 answer

AWS SAM template can't reference Security Group resource (created earlier outside the cloudfromation template)

I am writing a SAM template, I am trying to reference the security group id in the VpcConfig section in a lambda function as the following: VpcConfig: SecurityGroupIds: - !GetAtt aurora-mysql.GroupId SubnetIds: …
m.y.m
  • 347
  • 4
  • 27
0
votes
0 answers

How to have Lambda's destination working in SAM

I'm trying to figure out how to use the new destination feature, introduced here, to transfer data from one SQS queue, to another one, through a Golang lambda. Set up Following AWS documentation, I have build the following SAM template…
jugo
  • 161
  • 2
  • 10
0
votes
1 answer

How to ignore redundant files while deploying lambda in SAM project

I have SAM project structure like this: sam-app/ ├── README.md ├── events/ │ └── event.json ├── myTestLambda/ │ ├── app.py │ └── requirements.txt ├── template.yaml └── tests/ └── unit/ …
0
votes
0 answers

How can I most effectively mock/stub API Gateway, DynamoDB, and Cognito for integration testing an SPA?

I have a React-based SPA that I'm trying to test against a versioned backend with its own Database. In production, the part of the backend is exposed to the outside world via AWS services, like API Gateway. We also use DynamoDB for storing some…
0
votes
2 answers

How to add non authenticated routes in AWS SAM template

So this is my SAM template: webApi: Type: AWS::Serverless::Api Properties: Auth: DefaultAuthorizer: CognitoAuthorizer Authorizers: CognitoAuthorizer: UserPoolArn: !GetAtt myUserPool.Arn …
Matteo
  • 2,256
  • 26
  • 42
0
votes
1 answer

"Lambda function for the route not found" error running Golang function locally with SAM?

I'm attempting to write a Lambda function in Golang (doing development on my MacBook with Docker Desktop running) following this quick-start. I perform the following steps: Ran "sam init --runtime go1.x --name testing" to generate a function from…
Tyson
  • 1,685
  • 15
  • 36
0
votes
1 answer

AWS SAM AccessDeniedException on a Lambda that uses the AWS SDK

I have an AWS Lambda function in Node.js that uses the SDK method listVersionsByFunction. It's created from this AWS SAM template: AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Globals: Function: Timeout:…
Ed I
  • 7,008
  • 3
  • 41
  • 50
0
votes
1 answer

Configure Cloudformation to have requests to GET /subdirectory serve /subdirectory/index.html using Cloudfront & S3

I have a Cloudformation template that sets up a AWS::CloudFront::Distribution & AWS::S3::Bucket. Unfortunately, requests to GET /subdirectory respond with a 403. How can I configure the Cloudformation template to have GET /subdirectory serve…
0
votes
1 answer

InvalidResourceException when trying to "ref" an event in a function

I have a SAM template file that is throwing errors while doing sam build: [InvalidResourceException('MyFunction', "Type of property 'Events' is invalid.")] First off, at the top of my file (at the same level as Globals) I have this event (the idea…
ankush981
  • 5,159
  • 8
  • 51
  • 96
0
votes
1 answer

AWS serverless SAM - How to use implicit and explicit API definition simultaneously?

I got a .net core serverless application consisting of serveral lambda functions and I am using SAM for packaging and deployment. The lambda functions definition in the SAM template contain their implicit API definition (and I want to keep it that…
COeDev
  • 336
  • 3
  • 9