This repository contains the AWS Lambda based handler for Prismic.io webhooks that are run whenever the content is changed in Prismic. Handy for building/publishing content using AWS Services.
- Install Node 6.10 (usage of NVM or n highly suggested!)
- Install Serverless 1.12:
npm i -g [email protected]
(likely to work with newer versions, too) - Clone this repo:
git clone https://github.com/juhamust/prismic-lambda-webhook.git
- Install dependencies:
cd prismic-lambda-webhook && npm install -D
- Run the tests (optional):
npm test
- Set valid values in
env.yml
(or create copy likelocal.yml
and use --env=local while running commands). NOTE: API token is only needed if you want to use the actual sns -based handler examplePRISMIC_API_ENDPOINT: https://my-repo.prismic.io/api PRISMIC_API_TOKEN: see-prismic-api-settings PRISMIC_WEBHOOK_SECRET: my-secret
- Deploy the service:
sls deploy --profile=myawsprofile
- Copy the generated endpoint and your
PRISMIC_WEBHOOK_SECRET
and place them into Prismic.io Webhook settings - Tryout the trigger: It should be successfull. Check also AWS CloudWatch logs.
Sequence in short:
- User changes content in Prismic.io service
- Prismic triggers the webhook into address defined in settings.
- Webhook is handled (and authorized) by simple AWS Lambda based endpoint
- Lambda triggers SNS message with topic:
PRISMIC_LAMBDA_WEBHOOK
- Another service/lambda/whatever in AWS is triggered by the SNS (see
serverless.yml
andbuild.js
for example)
- Added Prismic.io build example
- Improved Serverless settings/options
- Initial release
MIT License