@dankochetov/commercetools-serverless-plugin

2.3.0 • Public • Published

CommerceTools Serverless plugin

Known Vulnerabilities contributions welcome

This plugin allows you to seamlessly integrate CommerceTools subscriptions and extensions with Serverless functions.

Installation npm version

npm i -D @dankochetov/commercetools-serverless-plugin

Configuration

custom:
  commerceTools:
    projectKey: string
    clientId: string
    clientSecret: string
    authHost: "https://auth.<region>.<provider>.commercetools.com/"
    apiHost: "https://api.<region>.<provider>.commercetools.com/"

Subscription

Only SQS destination is supported.

functions:
  Subscription:
    events:
      - commerceTools:
          subscription:
            createQueue: true # skip if queueArn is used
            batchSize: <number> # skip if queueArn is used
            queueArn: <arn> # skip if createQueue is used
            changes: # optional
              - resourceTypeId: product
              - ...
            messages: # optional
              - resourceTypeId: order
                types: # optional
                  - DeliveryAdded
                  - OrderStateChanged
                  - ...
              - ...
                

If you specify createQueue: true option, SQS queue will be created as a part of the current stack. Its batch size can be configured with the batchSize option and is set to 1 by default.

Extension

Only AWSLambda destination is supported.

functions:
  Extension:
    events:
      - commerceTools:
          extension:
            timeoutInMs: 1000 # optional
            triggers:
              - resourceTypeId: cart
                actions:
                  - Create
                  - Update
              - ...

How does it work?

For every subscription/extension configuration, the plugin adds the following list of resources to the template:

  • IAM user with minimal permissions and a set of security credentials;
  • CFN custom resource that manages the creation, modification and deletion of the subscription/extension;
  • (Subscriptions with createQueue: true only) SQS queue and corresponding sqs event to the function.

Contribution

After you change the code, don't forget to run npm run build to update the artifacts.

Readme

Keywords

none

Package Sidebar

Install

npm i @dankochetov/commercetools-serverless-plugin

Weekly Downloads

10

Version

2.3.0

License

MIT

Unpacked Size

124 kB

Total Files

5

Last publish

Collaborators

  • dankochetov