
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
serverless-plugin-simulate
Advanced tools
This is a proof of concept to see if we can replicate Amazon API Gateway using docker images to run lambda
This is a proof of concept to see if we can replicate Amazon API Gateway using docker images to run lambda
Install the plugin
npm i --save-dev serverless-plugin-simulate
Configure your service to use the plugin
service: my-service
provider:
name: aws
runtime: nodejs4.3 # python2.7 is also supported
# this is optional configurations
# servicesPathDest is use for the case u want to compile all your src and out
# put to another folder like dist
#
# services allows specifying a docker-compose.yml file and (optional)
# projectName. This will start the docker-compose stack when simulate is run.
# If projectName is specified, it will be used when running docker-compose,
# and the default docker-compose network will be passed to lambda docker commands
# allowing all lambdas to access any hosts defined in docker-compose services
custom:
simulate:
dist: dist
services:
file: docker-compose.yml
# will use: $ docker-compose --project-name myproject ...
# and: $ docker --network myproject_default ...
projectName: myproject
plugins:
- serverless-plugin-simulate
If you do not need to chain functions locally you can just run the API Gateway simulation by itself.
sls simulate apigateway -p 5000
If you want to chain functions locally, you need to use the Lambda Simulator.
Run the Lambda Simulation
sls simulate lambda -p 4000
Run the API Gateway Simulation
sls simulate apigateway -p 5000 --lambda-port 4000
Use the environment variables to configure the AWS SDK to use the local Lambda simulation. You can use the same technique with any other AWS SDK.
const AWS = require('aws-sdk');
const endpoint = process.env.SERVERLESS_SIMULATE ?
process.env.SERVERLESS_SIMULATE_LAMBDA_ENDPOINT :
undefined
const lambda = new AWS.Lambda({ endpoint })
const handler = (event, context, callback) => {
const params = {
FunctionName: 'my-other-function',
Payload: JSON.stringify({ foo: 'bar' })
}
lambda.invoke(params, (err, result) => {
if (err) {
return callback(err)
}
callback(null, {
statusCode: 200,
body: result.Payload
})
})
}
See the examples folder for examples.
npm install
- Installs all dependenciesnpm start
- Starts API Gateway simulation listening at http://localhost:5000npm run start:lambda
- Starts Lambda simulation listening at http://localhost:4000npm run start:apigateway
- Starts API Gateway simulation that uses the Lambda
simulation listening at http://localhost:5000npm run start:services
- Starts mock services defined in docker-compose.yml
npm test
- tests custom authorizer (Authorization:TOKEN 12345)See also the list of contributors who participated in this project.
Please create an issue before submitting an Pull Request.
This would not be possible without lambci
@johncmckim for suggesting the idea
FAQs
This is a proof of concept to see if we can replicate Amazon API Gateway using docker images to run lambda
The npm package serverless-plugin-simulate receives a total of 822 weekly downloads. As such, serverless-plugin-simulate popularity was classified as not popular.
We found that serverless-plugin-simulate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.