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

Prioritizing operational resiliency to reduce downtime in payments

2 min read - The average lost business cost following a data breach was USD 1.3 million in 2023, according to IBM’s Cost of a Data Breach report. With the rapid emergence of real-time payments, any downtime in payments connectivity can be a significant threat. This downtime can harm a business’s reputation, as well as the global financial ecosystem. For this reason, it’s paramount that financial enterprises support their resiliency needs by adopting a robust infrastructure that is integrated across multiple environments, including the…

Agility, flexibility and security: The value of cloud in HPC

3 min read - In today’s competitive business environment, firms are confronted with complex, computational issues that demand swift resolution. Such problems might be too intricate for a single system to handle or might require an extended time to resolve. For companies that need quick answers, every minute counts. Allowing problems to linger for weeks or months is not feasible for businesses determined to stay ahead of the competition. To address these challenges, enterprises across various industries, such as those in the semiconductor, life…

Field programmable gate arrays (FPGAs) vs. microcontrollers: What’s the difference?

6 min read - Field programmable gate arrays (FPGAs) and microcontroller units (MCUs) are two types of commonly compared integrated circuits (ICs) that are typically used in embedded systems and digital design. Both FPGAs and microcontrollers can be thought of as “small computers” that can be integrated into devices and larger systems. As processors, the primary difference between FPGAs and microcontrollers comes down to programmability and processing capabilities. While FPGAs are more powerful and more versatile, they are also more expensive. Microcontrollers are less…

IBM Newsletters

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