aws-sam-cli

deploy lambda to s3 bucket folder?

耗尽温柔 提交于 2019-12-07 08:34:27
问题 Here is the command to deploy the lambda: $ sam package --template-file sam.yaml --s3-bucket mybucket --output-template-file packaged.yaml But can I specify a bucket prefix? so it gets deployed to subfolder instead of root of bucket? 回答1: You can provide the bucket prefix using --s3-prefix parameter $ sam package --template-file sam.yaml --s3-bucket mybucket --s3-prefix path/to/file --output-template-file packaged.yaml Under the hood sam is calling aws command and all the options listed here

Recommended Project Structure for multi-function SAM Template

风格不统一 提交于 2019-12-05 18:12:11
I have a new project that requires a relatively small amount of services, maybe 10 or less (and therefore it is not economical to place each in a separate project repository). Each service will be defined as an AWS::Serverless::Function via SAM Template. My question is: what is the recommended way to organize or structure such a project? Currently the structure is: |- src |- lambdas |- service-one |- stuff |- package.json |- service-two |- stuff |- package.json |- other-stuff |- test |- package.json Is there a way to avoid having each lambda act as its own sub-project with unique package.json

Running AWS SAM projects locally get error

混江龙づ霸主 提交于 2019-12-05 05:25:45
I am trying to run an AWS Lambda project locally on Ubuntu. When I run the project with AWS SAM Local it shows me this error: Error: Running AWS SAM projects locally requires Docker. Have you got it installed? I had trouble installing it on Fedora. When I followed the Docker postinstall instructions I managed to get past this issue. https://docs.docker.com/install/linux/linux-postinstall/ I had to: Delete the ~/.docker directory; Create the "docker" group; Add my user to the "docker" group; Logout and back in again; Restart the "docker" daemon. I was then able to run the command: sam local

How to enable “ApiKeyRequired” property in SAM without explicit swagger definition?

廉价感情. 提交于 2019-12-04 04:43:06
问题 In cloudformation, AWS::ApiGateway::Method has a boolean property ApiKeyRequired . How can i achieve the same in SAM ? I know that we can enable using explicit swagger Configuration. which is like this { "swagger": "2.0", "info": { "version": "1.0", "title": { "Ref": "AWS::StackName" } }, "x-amazon-apigateway-api-key-source": "HEADER", "paths": { "/": { "get": { "x-amazon-apigateway-integration": { "httpMethod": "POST", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:aws:apigateway:${AWS:

How to enable “ApiKeyRequired” property in SAM without explicit swagger definition?

丶灬走出姿态 提交于 2019-12-01 21:35:20
In cloudformation, AWS::ApiGateway::Method has a boolean property ApiKeyRequired . How can i achieve the same in SAM ? I know that we can enable using explicit swagger Configuration. which is like this { "swagger": "2.0", "info": { "version": "1.0", "title": { "Ref": "AWS::StackName" } }, "x-amazon-apigateway-api-key-source": "HEADER", "paths": { "/": { "get": { "x-amazon-apigateway-integration": { "httpMethod": "POST", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${GetHelloWorld.Arn}/invocations" } }, "responses": {}, "security":

AWS lambda nodejs runtime: io: read/write on closed pipe

你。 提交于 2019-12-01 08:20:51
I am trying to execute a couple of async requests from a lambda function. The first call resolveEndpoints() succeeds and the second fails with 2017/11/03 17:13:27 Function oauth.callbackHandler timed out after 3 seconds 2017/11/03 17:13:27 Error invoking nodejs6.10 runtime: io: read/write on closed pipe The handler is: exports.callbackHandler = async (event, context, callback) => { context.callbackWaitsForEmptyEventLoop = false; let endpoints: any = await resolveEnpoints(); config.accessTokenUri = endpoints.token_endpoint; let tokenRequestPath = `http://localhost:7001${event.path}?code=${event

connecting AWS SAM Local with dynamodb in docker

时光总嘲笑我的痴心妄想 提交于 2019-11-28 05:05:24
I've set up an api gateway/aws lambda pair using AWS sam local and confirmed I can call it successfully after running sam local start-api I've then added a local dynamodb instance in a docker container and created a table on it using the aws cli But, having added the code to the lambda to write to the dynamodb instance I receive: 2018-02-22T11:13:16.172Z ed9ab38e-fb54-18a4-0852-db7e5b56c8cd error: could not write to table: {"message":"connect ECONNREFUSED 0.0.0.0:8000","code":"NetworkingError","errno":"ECONNREFUSED","syscall":"connect","address":"0.0.0.0","port":8000,"region":"eu-west-2",

connecting AWS SAM Local with dynamodb in docker

我只是一个虾纸丫 提交于 2019-11-27 00:46:27
问题 I've set up an api gateway/aws lambda pair using AWS sam local and confirmed I can call it successfully after running sam local start-api I've then added a local dynamodb instance in a docker container and created a table on it using the aws cli But, having added the code to the lambda to write to the dynamodb instance I receive: 2018-02-22T11:13:16.172Z ed9ab38e-fb54-18a4-0852-db7e5b56c8cd error: could not write to table: {"message":"connect ECONNREFUSED 0.0.0.0:8000","code":"NetworkingError