June 21, 2023 By Dimitri Prosper 3 min read

IBM Cloud Event Notifications is a service that can filter and route events received from other IBM Cloud services or custom applications to communication channels like email, SMS, push notifications, webhook, Slack, Microsoft® Teams, ServiceNow, IBM Cloud Code Engine and IBM Cloud Object Storage.

This post explores how you can create and configure the Event Notifications service using an Infrastructure as Code (IaC) template (in this case, Terraform) and configure an example application to send custom events. 

Architecture overview

  • Using an IaC tool, the infrastructure engineer deploys and configures the common infrastructure components that are required for a given solution. In this example, we focus on the minimum components required to demonstrate the usage of the services that are included:
    • Creating an instance of Event Notifications.
    • Configuring sources, topics, subscriptions and email destinations.
    • Configuring sources, topics, subscriptions and SMS destinations. 
    • Creating an instance of Cloud Object Storage and authorization between the Event Notifications and Cloud Object Storage instances, sources, topics, subscriptions and destinations.
  • The developer creates a new Code Engine project and deploys the application to the project. Although Code Engine is used in this example, the application could have also been deployed to a VPC virtual server instance or Kubernetes cluster.
  • The application generates a new event to the Event Notifications instance based on an internal event in the application. The event is delivered based on the subscriptions and destinations that are configured by the infrastructure engineer using the Terraform template. All events received through this API source are delivered to an Object Storage bucket.

The Event Notifications instance is configured to enable lifecycle events and an API source to receive both platform events and events from a custom application that is to be deployed by the application developer.

Configuring for lifecycle events

The Terraform template enables the resource lifecycle events default source and adds two filters for when new instances are created and deleted from the cloud environment. These events are reported by the IBM Cloud Resource Controller:

Configuring for application events

The Terraform template creates a new API source for the custom application events. It then configures a destination and subscription to a newly created Cloud Object Storage bucket using the private COS endpoints:

Generating the values required for the custom application

The custom application requires a few pieces of information to be able to forward its events to the Event Notifications instance. The template generates these values at the end so they can be handed over to the developer.

  • The location of the Event Notifications instance (i.e., instance_location).
  • The unique identifier for the Event Notifications instance (i.e., instance_guid).
  • A service credential is created for the application on the Event Notifications instance. This service credential has an api_key that is needed by the application to authenticate and pass events to the Event Notifications instance.
  • Finally, the api_source_name and api_source_id for the API source is provided.

Sending the custom event using the values provided

The application developer can include the values provided as environment variables to the application. They are used as shown below:

The payload in the event that is submitted is reduced since we know the subscriber to this event going will only go to a Cloud Object Storage bucket. Additional properties should be added based on the expected destination channel (learn more in the documentation).

Getting started

I hope you will find this example useful in your own projects. To get started, review the README in the repository on GitHub for step-by-step instructions on how to deploy this example.

Questions and feedback

If you have feedback, suggestions, or questions on this post, please reach out to me on LinkedIn. You can also open GitHub issues on the related code samples for clarification.

Learn more about IBM Cloud Event Notifications
Was this article helpful?
YesNo

More from Cloud

Bigger isn’t always better: How hybrid AI pattern enables smaller language models

5 min read - As large language models (LLMs) have entered the common vernacular, people have discovered how to use apps that access them. Modern AI tools can generate, create, summarize, translate, classify and even converse. Tools in the generative AI domain allow us to generate responses to prompts after learning from existing artifacts. One area that has not seen much innovation is at the far edge and on constrained devices. We see some versions of AI apps running locally on mobile devices with…

IBM Tech Now: April 8, 2024

< 1 min read - ​Welcome IBM Tech Now, our video web series featuring the latest and greatest news and announcements in the world of technology. Make sure you subscribe to our YouTube channel to be notified every time a new IBM Tech Now video is published. IBM Tech Now: Episode 96 On this episode, we're covering the following topics: IBM Cloud Logs A collaboration with IBM watsonx.ai and Anaconda IBM offerings in the G2 Spring Reports Stay plugged in You can check out the…

The advantages and disadvantages of private cloud 

6 min read - The popularity of private cloud is growing, primarily driven by the need for greater data security. Across industries like education, retail and government, organizations are choosing private cloud settings to conduct business use cases involving workloads with sensitive information and to comply with data privacy and compliance needs. In a report from Technavio (link resides outside ibm.com), the private cloud services market size is estimated to grow at a CAGR of 26.71% between 2023 and 2028, and it is forecast to increase by…

IBM Newsletters

Get our newsletters and topic updates that deliver the latest thought leadership and insights on emerging trends.
Subscribe now More newsletters