@cloudcomponents/cdk-contentful-webhook
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

cloudcomponents Logo

@cloudcomponents/cdk-contentful-webhook

Build Status cdkdx typescript python

Create, update and delete contentful webhooks with your app deployment

Install

TypeScript/JavaScript:

npm i @cloudcomponents/cdk-contentful-webhook

Python:

pip install cloudcomponents.cdk-contentful-webhook

How to use

import { ContentfulWebhook } from '@cloudcomponents/cdk-contentful-webhook';
import { SecretKey } from '@cloudcomponents/cdk-secret-key';
import { Stack, StackProps, aws_apigateway } from 'aws-cdk-lib';
import { Construct } from 'constructs';

export class ContentfulWebhookStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    const api = new aws_apigateway.RestApi(this, 'Endpoint');
    api.root.addMethod('POST');

    if (typeof process.env.ACCESS_TOKEN === 'undefined') {
      throw new Error('environment variable ACCESS_TOKEN undefined');
    }
    const accessToken = SecretKey.fromPlainText(process.env.ACCESS_TOKEN);

    if (typeof process.env.SPACE_ID === 'undefined') {
      throw new Error('environment variable SPACE_ID undefined');
    }
    const spaceId = process.env.SPACE_ID;

    const topics = ['Entry.create'];

    new ContentfulWebhook(this, 'ContentfulWebhook', {
      accessToken,
      spaceId,
      name: 'ExampleWebhook',
      url: api.url,
      topics,
      logLevel: 'debug',
    });
  }
}

API Reference

See API.md.

Example

See more complete examples.

License

MIT

Package Sidebar

Install

npm i @cloudcomponents/cdk-contentful-webhook

Weekly Downloads

121

Version

2.3.0

License

MIT

Unpacked Size

14 MB

Total Files

12

Last publish

Collaborators

  • hupe1980