Nuclear Powered Mushroom

    serverless-commercetools-plugin

    1.1.8 • Public • Published

    commercetools Serverless Plugin

    commercetools's plugin for the Serverless Framework allows you to seamlessly integrate your serverless functions with commercetools' extensibility options.

    Contents

    Features

    • Attach a newly deployed serverless function as a commercetools' API extension.
    • Create a new serverless function to process events from a commercetools' subscription.
    • Supports AWS and GCP

    Install

    npm i --save-dev serverless-commercetools-plugin
    # or 
    yarn add --dev serverless-commercetools-plugin

    Add the following plugin to your serverless.yml:

    plugins:
      - serverless-commercetools-plugin

    With the serverless CLI

    serverless plugin install --name serverless-commercetools-plugin

    Configuration

    Add your commercetools' project settings to the serverless.yaml file. Add these values under the provider section:

    provider:
      environment:
        CTP_PROJECT_KEY: "your_key"
        CTP_CLIENT_SECRET: "your_secret"
        CTP_CLIENT_ID: "your_clientid"
        CTP_AUTH_URL: "your_authurl"
        CTP_API_URL: "your_apiUrl"
        CTP_SCOPES: "your_scopes"

    API Extension

    Add environment vars for the deploy type ("extension") and your body configuration for the Extension.

        CTP_DEPLOY_TYPE: "extension"
        CTP_POST_BODY: '{
            "destination": {
              "type": "AWSLambda",
              "accessKey": "your_aws_key",
              "accessSecret": "your_aws_secret"
            },
            "triggers": [{
              "resourceTypeId": "cart",
              "actions": ["Create", "Update"]
            }]
        }'

    Note: The Lambda ARN is determined by the plugin. You do not need to include it in the configuration.

    For Google Cloud Platform functions set the CTP_POST_BODY to use the HTTP destination as outlined in the commercetools API Extension documentation.

    Subscription

    Add environment vars for the deploy type ("subscription") and your body configuration for the Subscription.

        CTP_DEPLOY_TYPE: "extension"
        CTP_POST_BODY: '{
            "destination": {
              "type": "AWSLambda",
              "accessKey": "your_aws_key",
              "accessSecret": "your_aws_secret"
            },
            "triggers": [{
              "resourceTypeId": "cart",
              "actions": ["Create", "Update"]
            }]
        }'

    Usage

    To build your cloud resources and configure the commercetools' project run:

    serverless deploy

    To remove all cloud resources and commercetools' configuration run:

    serverless remove

    Help

    If you have any issues, please don't hesitate to:

    When opening a new issue, please provide as much information as possible including:

    • Plugin version
    • node version
    • cloud environment
    • A reproducible code example

    The GitHub issues are intended for bug reports and feature requests specifically related to the serverless plugin.

    Development

    Create a local serverless function or copy the code from the examples folder. Add the plugin code to a folder named .serverless_plugins at the root of your serverless project.

    License

    Released as-is under the MIT license. See LICENSE for details.

    Install

    npm i serverless-commercetools-plugin

    DownloadsWeekly Downloads

    106

    Version

    1.1.8

    License

    MIT

    Unpacked Size

    83.5 kB

    Total Files

    18

    Last publish

    Collaborators

    • nspeet
    • luterek