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

IBM Cloud Reference Architectures unleashed

2 min read - The ability to onboard workloads to cloud quickly and seamlessly is paramount to accelerate enterprises digital transformation journey. At IBM Cloud, we're thrilled to introduce the IBM Cloud® Reference Architectures designed to empower clients, technical architects, strategists and partners to revolutionize the way businesses harness the power of the cloud. VPC resiliency: Strengthening your foundation Explore the resilience of IBM Cloud Virtual Private Cloud through our comprehensive resources. Dive into our VPC Resiliency white paper, a blueprint for building robust…

Enhance your data security posture with a no-code approach to application-level encryption

4 min read - Data is the lifeblood of every organization. As your organization’s data footprint expands across the clouds and between your own business lines to drive value, it is essential to secure data at all stages of the cloud adoption and throughout the data lifecycle. While there are different mechanisms available to encrypt data throughout its lifecycle (in transit, at rest and in use), application-level encryption (ALE) provides an additional layer of protection by encrypting data at its source. ALE can enhance…

Attention new clients: exciting financial incentives for VMware Cloud Foundation on IBM Cloud

4 min read - New client specials: Get up to 50% off when you commit to a 1- or 3-year term contract on new VCF-as-a-Service offerings, plus an additional value of up to USD 200K in credits through 30 June 2025 when you migrate your VMware workloads to IBM Cloud®.1 Low starting prices: On-demand VCF-as-a-Service deployments begin under USD 200 per month.2 The IBM Cloud benefit: See the potential for a 201%3 return on investment (ROI) over 3 years with reduced downtime, cost and…

IBM Newsletters

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