serverless-framework

Sharing Python code as a lambda layer using the Serverless framework

一个人想着一个人 提交于 2020-08-10 20:44:30
问题 This is a follow up question to: This Question I am trying to upload some shared Python code as a lambda layer to AWS Lambda using the serverless framework. I had followed @msc's solution (with some modifications): Project 1: Step 1: Create a serverless project with the following structure: ./ └ serverless.yml └ common/ └ python/ └ Other packages as per requirements.txt └ my_shared_script.py - my own package Step 2: Setup my .yml file: service: library provider: name: aws runtime: python3.7

AWS API Gateway request body as Java POJO for function

本小妞迷上赌 提交于 2020-07-09 14:53:37
问题 I was just having a really basic problem using aws-lambda, API Gateway and the serverless framework. I just wanted to hand over the body of a post request as a Java POJO. Okay, so here's the setup: POJO: public class Person { private String lastName; private string firstName; ... Setters and Getters omitted } Handler: public class PersonHandler implements RequestHandler<Person, ApiGatewayResponse> { @Override public ApiGatewayResponse handleRequest(lastNamePerson person, Context context) { //

aws-serverless-express connection error - EPIPE

别来无恙 提交于 2020-06-27 03:55:10
问题 We have a NodeJS 10.16.3 Express API. We've recently switched from AWS Elastic Beanstalk/EC2 to Lambda / Serverless. Our DB is Postgres (PostgreSQL) 12.2. It seemed all of a sudden I started getting this error on my local server when making requests from the client: offline: ANY /dev/inventory/inventory (λ: app) ERROR: aws-serverless-express connection error { Error: write EPIPE at WriteWrap.afterWrite (net.js:788:14) errno: 'EPIPE', code: 'EPIPE', syscall: 'write' } offline: (λ: app)

Reference function from within serverless.yml

感情迁移 提交于 2020-06-26 03:55:10
问题 I have several AWS lambdas running, supported by the Serverless Framework . I need one lambda (called lambdaOne ) which will call a second lambda (called lambdaTwo ) using AWS' javascript sdk. The issue is that I am getting an AccessDenied Exception when I attempt this: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AccessDeniedException: User: arn:aws:sts::12345678909876:assumed-role/test-dev-us-west-2-lambdaRole/test-dev-lambdaOne is not authorized to

How to pass parameters to serverless invoke local

六眼飞鱼酱① 提交于 2020-06-24 10:54:57
问题 I'm working on a aws serverless project and need to test the lambda functions locally. I am using serverless invoke local -f {function_name} command to test the API calls that does not request any path or query parameters. My question is how can I use this command to pass any path or query parameter to the function? Example serverless description getFoodDetails: handler: handler.getFoodDetails events: - http: method: get path: /foods/{food_id} cors: true request: parameters: paths: food_id:

Frequent timeout with app using Serverless Framework (AWS Lambda/Gateway), Express, Mongoose/MongoDB Atlas

早过忘川 提交于 2020-06-12 06:14:13
问题 Trigger warning : Beginner question. I built an api using Express and Mongoose with a MongoDB Atlas DB. Most of the time, it works normally, but often I get timeout errors. This seems to happen very randomly and concerns all routes, etc... Precisely, I get : `502 Internal server error via POSTMAN` and in the Serverless Dashboard, I get : invocation time invoked 1 day ago, mar 08 at 1:38pm fatal error Function execution duration going to exceeded configured timeout limit. cold start duration

Serverless framework TypeError: e is not a function

牧云@^-^@ 提交于 2020-05-15 09:27:26
问题 I'm using serverless-framework to schedule tasks in AWS. My application structure is |- src |- tasks |- analytics.task.js |- tasks.js |- serverless.yml The contents of analytics.task.js module.exports.run = (event, context, callback) => { console.log('Getting data...'); console.log('success'); }; Removed all other codes from the run method for testing purpose. content of tasks.js const analyticsTask = require('./src/tasks/analytics.task'); module.exports.analytics = analyticsTask.run(); and

How to deploy a serverless project bigger than one CloudFormation stack while lambda functions are having aliases

社会主义新天地 提交于 2020-04-30 09:19:02
问题 I'm trying to deploy a serverless yaml file that does not fit into a single CloudFormation stack. Searching online, it seems there are plugins for that. So far, I've tested serverless-plugin-split-stacks . It works but... I managed to deploy my project which includes more than 200 CloudFormation resources (I couldn't do this without the aforementioned plugin). It's just that, I need to use the serverless-aws-alias plugin as well. Previously, without the serverless-plugin-split-stacks plugin,

How to deploy a serverless project bigger than one CloudFormation stack while lambda functions are having aliases

倖福魔咒の 提交于 2020-04-30 09:18:43
问题 I'm trying to deploy a serverless yaml file that does not fit into a single CloudFormation stack. Searching online, it seems there are plugins for that. So far, I've tested serverless-plugin-split-stacks . It works but... I managed to deploy my project which includes more than 200 CloudFormation resources (I couldn't do this without the aforementioned plugin). It's just that, I need to use the serverless-aws-alias plugin as well. Previously, without the serverless-plugin-split-stacks plugin,

Mock response data with serverless framework

烂漫一生 提交于 2020-04-16 05:54:06
问题 The docs give the following as a mock example: functions: hello: handler: handler.hello events: - http: path: hello cors: true method: get integration: mock request: template: application/json: '{"statusCode": 200}' response: template: $input.path('$') statusCodes: 201: pattern: '' This does create a mock response...except it's empty. How can I actually return data here? I've tried adding application/json: {...} to template , but that doesn't work, I've tried adding a body under statusCodes