serverless-plugin-api-gateway-integrations
v0.0.8
Published
Serverless plugin to add API Gateway integrations
Downloads
4
Maintainers
Readme
serverless-plugin-api-gateway-integrations
Note: If you're missing any capability please open an issue/feature request :)
Introduction
I wrote this plugin since I wanted to wrap my lambda with an SQS queue. I found that there is a lot of boilerplate when writing SQS API Gateway integration hence this plugin. I'm open to adding more integrations and configuration options :)
Installation
Install with yarn
yarn add serverless-plugin-api-gateway-integrations --dev
or npm
npm install serverless-plugin-api-gateway-integrations --save-dev
Usage
In your serverless.yml
under plugins
add
plugins:
- serverless-plugin-api-gateway-integrations
Under custom
add:
custom:
apiGatewayIntegrations:
- { type: sqs, name: 'queue' } # only sqs is supported at the moment
You can reference the created queues' ARNs by using Pascal case naming:
functions:
consumer:
events:
- sqs:
arn: !GetAtt ApiGatewayIntegrationSqsQueue.Arn
errorHandler:
events:
- sqs:
arn: !GetAtt ApiGatewayIntegrationSqsQueueDlq.Arn
The plugin will create an API gateway (or use the existing default one if exists), and add all the necessary resources, methods and roles (with cors support).
Then you can do:
curl -d '{"message":"Hello World!"}' -H "Content-Type: application/json" -X POST https://*************.execute-api.us-east-1.amazonaws.com/dev/queue