0.0.8 • Published 6 years ago
serverless-plugin-api-gateway-integrations v0.0.8
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 --devor npm
npm install serverless-plugin-api-gateway-integrations --save-devUsage
In your serverless.yml under plugins add
plugins:
- serverless-plugin-api-gateway-integrationsUnder custom add:
custom:
apiGatewayIntegrations:
- { type: sqs, name: 'queue' } # only sqs is supported at the momentYou 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.ArnThe 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