Questions tagged [aws-sam-cli]

AWS SAM Local allows developers to run & debug AWS Lambda code on local machine using Docker. AWS Lamda is a part of Amazon Web Services (AWS).

AWS SAM Local allows developers to run & debug AWS Lambda code on local machine using Docker. AWS Lamda is a part of Amazon Web Services (AWS).

Resources

512 questions
13
votes
6 answers

AWS Lambda Sam can't find docker

I'm trying to test my hello world lambda function with aws-sam-cli using the following command in my project root folder: sam local start-api --debug This gives me the following output in the console: 2018-07-11 16:13:15 local start-api command is…
J. Leander
  • 354
  • 1
  • 2
  • 12
13
votes
1 answer

How do I excluded folder from sam deploy command?

I run this to deploy my lambda: sam package --template-file prod_template.yaml --s3-bucket mybucket --output-template-file packaged-template.yaml sam deploy --template-file packaged-template.yaml --stack-name mystack --capabilities…
red888
  • 27,709
  • 55
  • 204
  • 392
12
votes
3 answers

How to add environment variables in template.yaml in a secured way?

When creating Lambda function through the SAM CLI using template.yaml, I have to pass few environment variables, and they shouldn't be exposed on GitHub. Is there any way I can refer the environment variables in template.yaml through the .env…
Nandy
  • 666
  • 1
  • 12
  • 27
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
3 answers

How to debug in VS Code a local AWS Lambda function with API Gateway written in TypeScript?

We are about to start working with Lambda functions. We have that technology constraint that we have to use TypeScript. I want to be able to debug my ts file in VS Code when the related endpoint is called from Postman. So, we have the following…
Peter Csala
  • 17,736
  • 16
  • 35
  • 75
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
4 answers

How to install AWS SAM CLI on Linux without Brew

Update on Dec 2020 The AWS github issue is Provide linux installation without homebrew #1424. Please monitor the update in the github issue for the latest status. AWS finally decided to provide non brew approach. we have work currently underway to…
mon
  • 18,789
  • 22
  • 112
  • 205
12
votes
6 answers

mysql data base connection inside Sam local

I am trying to do local development setup for serverless architecture. Amazon provide SAM Local Beta for doing so. But in my project we are using mysql database. I am trying to make a connection to my local mysql server it failed saying. module…
Tinkesh Kumar
  • 171
  • 1
  • 1
  • 4
11
votes
4 answers

SAM CLI executable not found - Pycharm

I'm trying to configure PyCharm in order to run a Lambda Function. First of all in AWS Toolkit I select the SAM CLI executable, and it goes well: Anyway, when I want to add a Lambda run configuration pycharm says: Invalid sam executable: "The…
Xevi
  • 379
  • 1
  • 2
  • 11
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
2 answers

What is the cause of the Security Constraints Not Satisfied Error when using sam deploy ---guided?

I am attempting to follow the Hello World example for deploying an AWS Serverless Application, but I get a Security Constraints Not Satisfied Error when using sam deploy --guided. I'm pressing Enter at each prompt to accept the defaults per the…
Kyle D. Hebert
  • 131
  • 1
  • 6
10
votes
1 answer

IntelliJ IDEA Config cant find AWS Lambda Handler in Default 'helloworld' Application

When setting the debug configurations for the default IntelliJ IDEA Java helloworld application (created upon making a new AWS Lambda project) the following response is shown: Error: Cannot find handler 'helloworld.App::handleRequest' in…
David
  • 256
  • 2
  • 13
10
votes
4 answers

Enable CORS when running AWS SAM CLI locally

Whenever I try to access serverless lambda function via POST through the browser I get the error Response to preflight request doesn't pass access control check: No >'Access-Control-Allow-Origin' header is present on the requested resource. When…
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
1 answer

AWS SAM CLI throws error: Error building docker image

I am trying to use the SAM CLI on my M1 Mac. I followed the steps outlined in these docs: sam init cd sam-app sam build sam deploy --guided I did not modify the code or the yaml files. I can start the local Lambda function as expected: ➜ sam-app…
1
2
3
34 35