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

How Wasabi and IBM help clients deliver on data-driven innovation

2 min read - Last year, Wasabi Technologies and IBM Cloud® joined forces to drive data innovation across hybrid cloud environments, positioning enterprises to run applications across any environment—on premises, in the cloud or at the edge—and enabling users to cost efficiently access and use key business data and analytics in real time. As we head into the second half of 2024, IBM Cloud and Wasabi continue to build new ways to expand their relationship. This growing relationship has the potential to reshape how…

Unlocking business value: Maximizing returns from your SAP investments

3 min read - Amid the dynamic realms of modern business and technology, organizations seek to maintain a competitive edge and elevate business outcomes and user experiences through their SAP investments. The crux of this endeavor lies in fostering continuous value creation throughout the journey. Drawing from my experience with clients across expansive, multi-year SAP engagements, there are three areas where collaborative value creation and charting future roadmaps intertwine seamlessly. 1. Value assurance throughout the engagement journey: Value assurance is the cornerstone of every…

Maximize business outcomes on IBM Cloud with Concierge Platinum Services

2 min read - In the rapidly evolving digital landscape, we see that businesses are increasingly migrating to cloud services to enhance their operations, boost productivity and foster innovation. However, the process of transitioning clients to the cloud can often be intricate and time-intensive. To tackle this challenge head-on, IBM® offers clients access to a specialized Concierge Platinum Team, which is equipped with top-tier skills and expertise, to help expedite the cloud onboarding process and provide a smooth transition to Day Two Operations. What…

IBM Newsletters

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