serverless-offline | Emulate AWS λ and API Gateway | Cloud Functions library
kandi X-RAY | serverless-offline Summary
kandi X-RAY | serverless-offline Summary
This Serverless plugin emulates AWS λ and API Gateway on your local machine to speed up your development cycles. To do so, it starts an HTTP server that handles the request's lifecycle like APIG does and invokes your handlers. This plugin is updated by its users, I just do maintenance and ensure that PRs are relevant to the community. In other words, if you find a bug or want a new feature, please help us by becoming one of the contributors :v: ! See the contributing section.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Removes a file from cache
- Render a single velocity string .
- Determines whether or not the two arguments are strings
- Extracts api request object from the resource path
- Construct the Hapi interface object
- Logs routes
- Get the full path of a resource
- Escape code to a JavaScript object .
- Check if all statements on a specific policy .
- Gets the parent ID for a resource .
serverless-offline Key Features
serverless-offline Examples and Code Snippets
plugins:
- serverless-webpack
- serverless-offline #serverless-offline needs to be last in the list
plugins:
- serverless-iot-local
- serverless-offline
sudo npm uninstall -g serverless
sudo npm i -g serverless
npm i -D serverless-offline
service:
name: api-base
frameworkVersion: ">=1.2.0 <2.0.0"
plugins:
- serverless-plugin-optimize
- serverless-offline
- serverless-pseudo-parameters
- serverless-domain-manager
custom:
stage: ${self:provider.stage, 'd
#index.js# file
const express = require('express')
const app = express()
const sls = require('serverless-http')
const path=require('path')
const StaticFileHandler = require('serverless-aws-static-file-handler')
var
Community Discussions
Trending Discussions on serverless-offline
QUESTION
I'm playin around with Serverless and I have no luck getting serverless-offline
to work with serverless-dynamodb-local
.
I have very minimal setup, it takes 3minutes to reproduce, I did it like this:
- Generate a TS Serverless project like -
sls create -t aws-nodejs-typescript --path folder-name
- install dependencies
npm i
- Add DynamoDB local
npm install --save serverless-dynamodb-local
- Add serverless offline
npm install serverless-offline --save-dev
- Install dynamodb
sls dynamodb install
Now I update serverless.ts
file like
- Include installed plugins in the correct order
ANSWER
Answered 2022-Apr-11 at 10:19Turns out it's most likely an environment issue of my MacBook. My friend tried exactly the same code on his computer and it was working for him.
Still if anyone has an idea why this might be happening let me know please.
EDIT:
So turned out it was a problem with my node version, I was running v17.3.1
. After switching to v16.4.0
it works like a charm. 🥳
QUESTION
Am getting an error when I am deploying serverless lambda function on AWS
...ANSWER
Answered 2022-Feb-23 at 22:18You are developing a NodeJS + Webpack + Sequelize + pg + pg-hstore application. You compile everything and when you execute your webpack bundle, you have the following error
QUESTION
It's 3 days i am on this problem of E2E tests on my GraphQL application with NestJS + Apollo / Express.
When I am running my app with serverless offline or directly with my main file, it's working perfectly. I have my graph and all things I need :)
But, when I am running E2E tests with Jest, I received an error from the await app.init()
inside the beforeEach
.
After playing with the package.json and dependencies, the error throwed is TypeError: (0 , schema_1.makeExecutableSchema) is not a function
.
Someone have any idea please ? I am totally blocked ... :(
...ANSWER
Answered 2022-Feb-20 at 14:45After many hours of intense programming ... I finally found the problem.
Be careful if you use some "alias" for imports, because it can overwrite some of the packages used.
Here, i use the @graphql
alias, and it breaks all my tests.
When I remove it, the problem disappear.
QUESTION
I'm trying to use serverless framework with a python project. I created a hello world example that I run in offline mode. It works well but when I try to import a python package I get ModuleNotFoundError.
Here is my serverless.yaml file:
...ANSWER
Answered 2022-Feb-16 at 13:29Your lambda function don't have the panda module installed
You need to use the serverless-python-requirements
plugin : https://www.serverless.com/plugins/serverless-python-requirements. To use it you need docker on your machine and to create a requirement.txt
file in your service with the packages you need in your lambda
QUESTION
I have the following serverless.yml file:
...ANSWER
Answered 2022-Feb-08 at 12:55Thanks to @eli6 for the tip about serverless print. I don't know the root cause of the problem but after restarting vscode serverless print and serverless deploy then worked
QUESTION
I have a problem with @nestjs/graphql with serverless.
When i start the app normaly with the $ nest start
command, it's working well without any error.
But with the $ sls offline
command, it's not running and i have this error when i go to the /graphql (playground) endpoint :
ANSWER
Answered 2022-Feb-05 at 14:51According to this page https://docs.nestjs.com/graphql/unions-and-enums
enums need to be declared with the function registerEnumType
QUESTION
I use nodejs s3 package "aws-sdk" It works fine when I use serverless-offline run on my mac. The s3.getSignedUrl and s3.listObjects function both work fine.
But when I run my deployed app, the s3.getSignedUrl works fine but the s3.listObjects not. I got this error in CloudWatch:
In CloudWatch > Log groups > /aws/lambda/mamahealth-api-stage-userFilesIndex:
...ANSWER
Answered 2021-Dec-27 at 10:54In the last line of your IAM role, you grant permissions the lambda function to perform s3:PutObject
, s3:GetObject
, s3:DeleteObject
and s3:ListBucket
on the S3MasterResourceBucketArn/*
.
I believe that the first 3 actions and the last one have different resource requirements. For the first 3 (PutObject, GetObject, and DeleteObject) the resource name is correct. For the last one (ListBucket) I believe it must be the arn of the bucket without the star at the end (``S3MasterResourceBucketArn`).
As a good practice, you should split your policy into multiple statements, like:
QUESTION
i have deployed a aws lambda app that uses dynamodb but when i run the lambda fuction i am getting following errors
...ANSWER
Answered 2021-Dec-20 at 06:48The role assumed by your lambda function does not have required permissions to access the Dynamo Db table. To solve this, you need to attach the appropriate policy to your lambda function role.
This page contains a policy that grants Read/Write access to your lambda function.
QUESTION
In my sls project, I setup sqs offline usage as shown below using this article.
- npm installed serverless-offline-sqs as dev dependency
- Included serverless-offline-sqs after serverless-offline in serverless.ts plugins section
- Added custom configuration for the Queue,
ANSWER
Answered 2021-Dec-15 at 18:03Figured it out. Nothing wrong with plugin. Though I added lambda function handler for SQS events, I forgot to include the function in serverless.ts under "functions" resource. Including it in functions autoCreated the queue as expected.
QUESTION
Currently I am facing an issue while trying to bind my serverless handlers to my vpc. My command to deploy is the following:
...ANSWER
Answered 2021-Dec-15 at 16:51After some research we were able to connect our lambda to our vpc using serverless. The solution was: Stop using serverless-vpc-plugin
.
It turns out that serverless-vpc-plugin
, automatically creates a AWS VPC, which is not what we were looking for. We already had our VPC created using terraform.
From serverless-vpc-plugin documentation
Automatically creates an AWS Virtual Private Cloud (VPC) using all available Availability Zones (AZ) in a region.
In other words, serverless-vpc-plugin
doesn't make sense when the target vpc already exists
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverless-offline
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page