@dankochetov/commercetools-serverless-plugin
v2.3.0
Published
Commercetools Serverless plugin
Downloads
6
Readme
CommerceTools Serverless plugin
This plugin allows you to seamlessly integrate CommerceTools subscriptions and extensions with Serverless functions.
Installation
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 correspondingsqs
event to the function.
Contribution
After you change the code, don't forget to run npm run build
to update the artifacts.