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

Custom build step for SAM CLI

When using the AWS SAM CLI to build a serverless application, it located dependencies magically and installs them all as the "build" step. For example, using a NodeJS application: $> sam build Building resource 'HelloWorldFunction' Running…
stevendesu
  • 15,753
  • 22
  • 105
  • 182
7
votes
4 answers

AWS SAM: Shared files across Lambda functions

I am working with AWS SAM (Serverless Application Model) to build Python 3.6 lambda code in an API Gateway setup. As such, I have a single template.yaml file that creates several Lambda functions. They are organized with the lambda functions each…
Hephaestus
  • 4,337
  • 5
  • 35
  • 48
7
votes
2 answers

API Gateway HTTP Proxy integration with aws-sam (NOT Lambda Proxy)

I am trying to use aws-sam to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this: All of the aws-sam examples which I've found, as well as related…
Daniel B.
  • 1,650
  • 1
  • 19
  • 40
7
votes
2 answers

aws sam publish/deploy flow

I'm not fully grasping the flow with publishing/deploying with sam. My biggest hiccup is that my sam template declares a AWS::Serverless::Function and the CodeUri parameter forces me to put in a s3 bucket url. I've seen examples where the CodeUri is…
TemporaryFix
  • 2,008
  • 3
  • 30
  • 54
7
votes
0 answers

import common python file in codeUri in template.yaml for sam applications

I have the follwing folder structure src -- foo --lambda1.py -- blah --lambda2.py -- util --util.py Now i would to create to include util.py in both the lambda functions code uri using the template.yaml.So that i dont have to maintain…
7
votes
2 answers

Setting environmental variables with !Ref in AWS SAM?

I'm using SAM CLI v0.8.1. I'm trying to set environmental variable MY_TABLE_VAR as name of the table in my resources (MyTableResource). However, while running my app locally, the MY_TABLE_VAR is undefined. Can you tell me what's wrong in my template…
Mahdi
  • 1,089
  • 1
  • 14
  • 27
7
votes
1 answer

sam local start-api gives error while testing SAM application in local

Hi i have a sam application which one lambda function and can be invoked from rest endpoint which is working as expected but when i try to test the sam application locally using sam local start-lambda or sam local start-api or sam local invoke i…
7
votes
1 answer

How to enable ApiKeyRequired for an Api Method?

I want to use the standard API Keys feature of API Gateway. If I use standard cloudformation this is possible by setting the property ApiKeyRequired to true for a method. How can I do this with SAM? I tried using swagger but that does not seem to…
user3492652
  • 119
  • 1
  • 6
7
votes
1 answer

Run AWS SAM Local on another port

I've been successful in running AWS SAM Local on my machine on port 3000 with this command: sam local start-api The documentation says there's a flag -d that runs the server in debug mode on a different port. I need to run this on port 8080. So I…
serverpunk
  • 10,665
  • 15
  • 61
  • 95
7
votes
0 answers

Nested Fn::ImportValue in Fn::Sub not working for SAM template

Description: I am trying to define Serverless API resource. But having trouble in defining location of swagger specification file using function ImportValue. Steps to reproduce the issue: I am not able to define AWS::Serverless::Api resource having…
7
votes
1 answer

SAM Local: Can you use a CloudFormation file directly instead of SAM Template?

I am trying to use a compiled CloudFormation file directly with SAM Local. I cannot find a way to do this, has anyone achieved this successfully?
Drakken Saer
  • 859
  • 2
  • 10
  • 29
7
votes
1 answer

How can I change the name of the API stage in a SAM template?

I'm using SAM to deploy a Lambda function and make it callable over HTTP with via API Gateway using roughly this template snipplet: MyFunction: Type: AWS::Serverless::Function Properties: … Events: MyApi: Type: Api …
Theo
  • 131,503
  • 21
  • 160
  • 205
6
votes
1 answer

How to run multiple lambda functions when deploying as a Docker image?

How does the dockerfile look like for aws lambda with docker image via aws-sam when declaring multiple functions/apps in templates.yaml? Here is the sample dockerfile to run "a single app" FROM public.ecr.aws/lambda/python:3.8 COPY app.py…
xtremeHitori
  • 63
  • 1
  • 5
6
votes
2 answers

How to pass AWS SAM deploy a list of capablities?

I'm trying to pass multiple capabilities to sam deploy sam deploy --guided --capabilities "CAPABILITY_IAM CAPABILITY_AUTO_EXPAND" I have tried different forms of this, essentially encoding the list as an array with "[CAPABILITY_IAM,…
Josh Russo
  • 3,080
  • 2
  • 41
  • 62
6
votes
2 answers

Manage stage and prod environments in AWS SAM/Cloudformation template along with CI/CD support

I'm having an AWS SAM template file with some resources hosted on github, a codepipeline has been setted up to detect changes in the repo then create/update and execute changes on cloudformation stack. Everything is working fine. But now I need to…