Overview
The integration between App builder project and I/O Events allows to create applications that listen to Adobe events. Automatic events registrations push this concept further by subscribing your newly deployed project to I/O Events automatically, so you can easily deploy your application in different environments or even share your application with other organizations. Also, this technology minimizes the manual routine work for admins and reduces the possibility to mess up things during manual setup in Developer Console.
Creating self-contained application
In this chapter, we will create a code that listens to a specific event type and bind itself to this event type.
- Create App Builderproject(Runtime) with webhook using App builder project and I/O Events article. DON'T go toDeveloper Consoleto create registrations!
- Install aio-cli-plugin-extensionplugins using AIO CLI(aio plugins discover -i)
- Declare your action as non-weband setrequire-adobe-authtofalseinapp.config.yamlfile. Actions deployed withaio-cli-plugin-extensionplugin only receive events signed by Adobe I/O Events. All other invocations will be ignored.
- Define the event types you want to receive in event-listener-forsection ofapp.config.yamlfile like the following:
application:
  actions: actions
  web: web-src
  runtimeManifest:
    packages:
      appbuilder:
        license: Apache-2.0
        actions:
          generic:
            function: actions/generic/index.js
            web: 'no'
            runtime: 'nodejs:14'
            inputs:
              LOG_LEVEL: debug
            annotations:
              require-adobe-auth: false
            relations:
              event-listener-for:
                - {{YOUR_EVENT_TYPE}}
- Launch App Builderdevelopment session usingaio app runCLI command. This command will partially deploy your application, continuously synchronize your changes and create registrations for events declared in the manifest file.
- Terminate the development session when you are done coding using CTRL+C. This will clean up all registrations created during the development session.
Sequences
A similar approach can be used for OpenWhisk sequences. See the following example:
application:
  actions: actions
  web: web-src
  runtimeManifest:
    packages:
      appbuilder:
        license: Apache-2.0
        actions:
          generic:
            function: actions/generic/index.js
            web: 'no'
            runtime: 'nodejs:14'
            inputs:
              LOG_LEVEL: debug
        sequences:
          test:
            actions: generic
            annotations:
              require-adobe-auth: false
            relations:
              event-listener-for:
                - {{YOUR_EVENT_TYPE}}
Deploy self-contained application
- Launch aio app deployAIO CLI command.
Congratulations, you just deployed the code and it's already subscribed to the specified event type. You can now share the code and repeat aio app deploy command on any environment you need
Remove self-contained application
- Launch aio app undeployAIO CLI command. This command removes the application and also removes all event registrations bound to this application
Usage in CI/CD environment
When IMS organization contains multiple suitable event providers, this plugin asks the user to select one manually. This behavior works for many user scenarios, but it may cause issues in CI/CD environment. In such cases, PREFERRED_PROVIDERS will help to specify a list of provider ids that will be selected automatically.
Example: PREFERRED_PROVIDERS=c021fed7-54f3-4137-b7d0-1f3abb2e9902,dfa1319c-83ab-406e-869a-067cf89c65ba aio app deploy
If some event type is present in both specified preferred providers, the plugin selects the first suitable provider according to the position in the list.
Links
- https://github.com/adobe/aio-cli-plugin-extension - the source code & additional documentation
- https://www.npmjs.com/package/@adobe/aio-cli-plugin-extension - npm package