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

A clear path to value: Overcome challenges on your FinOps journey 

3 min read - In recent years, cloud adoption services have accelerated, with companies increasingly moving from traditional on-premises hosting to public cloud solutions. However, the rise of hybrid and multi-cloud patterns has led to challenges in optimizing value and controlling cloud expenditure, resulting in a shift from capital to operational expenses.   According to a Gartner report, cloud operational expenses are expected to surpass traditional IT spending, reflecting the ongoing transformation in expenditure patterns by 2025. FinOps is an evolving cloud financial management discipline…

IBM Power8 end of service: What are my options?

3 min read - IBM Power8® generation of IBM Power Systems was introduced ten years ago and it is now time to retire that generation. The end-of-service (EoS) support for the entire IBM Power8 server line is scheduled for this year, commencing in March 2024 and concluding in October 2024. EoS dates vary by model: 31 March 2024: maintenance expires for Power Systems S812LC, S822, S822L, 822LC, 824 and 824L. 31 May 2024: maintenance expires for Power Systems S812L, S814 and 822LC. 31 October…

24 IBM offerings winning TrustRadius 2024 Top Rated Awards

2 min read - TrustRadius is a buyer intelligence platform for business technology. Comprehensive product information, in-depth customer insights and peer conversations enable buyers to make confident decisions. “Earning a Top Rated Award means the vendor has excellent customer satisfaction and proven credibility. It’s based entirely on reviews and customer sentiment,” said Becky Susko, TrustRadius, Marketing Program Manager of Awards. Top Rated Awards have to be earned: Gain 10+ new reviews in the past 12 months Earn a trScore of 7.5 or higher from…

IBM Newsletters

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