serverless-framework

Serverless Framework - Python and Requirements.txt

我是研究僧i 提交于 2019-12-18 04:01:58
问题 Using the serverless framework v1.0.0, I have a 'requirements.txt' in my service root with the contents being the list of dependant python packages. (e.g. requests). However my resulting deployed function fails as it seems these dependencies are not installed as part of the packaging 'Unable to import module 'handler': No module named requests' I assume it is serverless that does the pip install, but my resulting zip file is small and clearly its not doing it, either by design or my fault as

MongoDB NodeJS driver's browserify compatibility (debugging help)

拜拜、爱过 提交于 2019-12-14 03:22:04
问题 Trying to figure out what's the problem that I can't browserify mongodb native nodejs driver. I'm assuming there is something wrong here in my setup as I tried googling if there was any known current compatibility problem with MongoDB NodeJS driver and browserify but nothing conclusive came up after couple days trying ;( After running my code on browserify I get a TypeError: require(...).native is not a function I read on the driver's github repo that this driver depends on some native

What's the correct way of returning HTTP error codes in serverless lambda

北城以北 提交于 2019-12-13 14:45:08
问题 I have a serverless lambda function written in Node.JS. What is the best / correct way of returning error codes? The pattern that I use right now ( and it works! ) is: module.exports.endpoint = (event, context, callback) => { const response = { statusCode: 404, body: JSON.stringify({ message: 'Hello World!' }) }; callback(null, response); } When I make a call, for example from POSTMAN, to my endpoint I get: Status: 404 Not Found which is exactly what I'm expecting . Moreover, in the logs I

serverless-webpack Cannot find module './node/NodeTemplatePlugin'

江枫思渺然 提交于 2019-12-13 13:51:40
问题 I'm trying to use the serverless-webpack plugin, and while running webpack alone works just fine, attempting to run serverless-webpack fails with Cannot find module './node/NodeTemplatePlugin' . My serverless.yml file is as follows: service: kamehameha provider: name: aws runtime: nodejs6.10 functions: getDeltas: handler: bundle.getDeltas plugins: - serverless-webpack And my webpack config is as follows: let path = require("path") let webpack = require("webpack") let nodeExternals = require(

Cognito user pool authorizer With Serverless Framework

廉价感情. 提交于 2019-12-13 11:36:15
问题 I need to authorize my API end point using aws cognito userpool. I can do it manually, but I need to automate the authorization part with the serverless framework. Does the Serverless framework have support for aws cognito? If so, how do we setup an aws-userpool with serverless? 回答1: Yes . Serverless ( v1.5 ) support to Cognito user pool authorizer. If you use previous version of serverless you have to update v1.5 or later. For the user-pool authorization of api end point you have to specify

Docx Document Serverless S3 Error while Putobject Method

人走茶凉 提交于 2019-12-13 03:54:11
问题 I am stuck in a situation for a long time. I am trying to upload a docx file to S3 bucket , using Serverless framework I was successful in uploading the docx document to S3 bucket.But what happened is, when I opened the document from S3. The document contained a buffer data converted to base64 string. i.e the big string about 23 pages. The docx was corrupted. MY Code exports.putFile = async(event) =>{ try { var bitmap = fs.readFileSync('./test.docx'); let bufferValue = new Buffer(bitmap)

How to do serverless binary configuration right

馋奶兔 提交于 2019-12-13 03:20:21
问题 I started with this example. ... ended up with this failing code. I wanted to return a simple pdf file. I find that SLS is not converting to binary. Here is the serverless.yml file. functions: hello: handler: handler.hello description: Can we display a PDF? events: - http: path: hello method: get contentHandling: CONVERT_TO_BINARY plugins: - serverless-apigw-binary - serverless-apigwy-binary custom: apigwBinary: types: - 'application/pdf' And here is the handler 'use strict'; var fs = require

creating dialogflow v2 project with serverless

瘦欲@ 提交于 2019-12-13 02:56:44
问题 Having issues trying to run a new AWS/Serverless/Dialogflow project. I am sure it is something simple that I am just not seeing. Steps Created initial project using: serverless create --template aws-nodejs-typescript moved handler.js to src/ & updated serverless.yml npm installed actions-on-google followed the actions-on-google example and updated src/handler.js import { dialogflow, Image } from 'actions-on-google'; const app = dialogflow({debug: true}); app.intent("test.intent", (conv) => {

How to increase NodeJS heap (--max-old-space-size) in Bitbucket Pipelines for Typescript/Webpack?

故事扮演 提交于 2019-12-12 20:45:49
问题 I am running into memory issues during the webpack packaging step in a serverless/TypeScript project. I have tried: 'increase-memory-limit' npm package to no avail Calling the following command from an npm run script Calling the following command directly through bitbucket-pipelines.yml. node --max-old-space-size=4096 ./node_modules/.bin/serverless deploy It works fine locally with this command, but in Bitbucket pipelines I get the following output: Serverless: Bundling with Webpack...

AWS Lambda with Nodejs native modules

流过昼夜 提交于 2019-12-12 18:42:39
问题 Recently I started with AWS Lambda functions, my Nodejs application was working well until I tried to use web3.js package. After I added the line const Web3 = require('web3'); I got the error "Internal Server Error" for the HTTP endpoint, and the following in CloudWatch logs module initialization error: Error at Object.Module._extensions..node (module.js:681:18) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require