This module manages notification topics and subscriptions in Oracle Cloud Infrastructure (OCI) based on a single configuration object. OCI Notifications service enables the configuration of communication channels for publishing messages using topics and subscriptions. When a message is published to a topic, the Notifications service sends the message to all of the topic's subscriptions.
Check module specification for a full description of module requirements, supported variables, managed resources and outputs.
Check the examples folder for actual module usage.
This module requires Terraform binary version 1.3.0 or greater, as it relies on Optional Object Type Attributes feature. The feature shortens the amount of input values in complex object types, by having Terraform automatically inserting a default value for any missing optional attributes.
This module requires the following OCI IAM permissions in the compartments where topics and subscriptions are defined.
Allow group <group> to manage ons-family in compartment <compartment-name>
Terraform modules can be invoked locally or remotely.
For invoking the module locally, just set the module source attribute to the module file path (relative path works). The following example assumes the module is two folders up in the file system.
module "notifications" {
source = "../.."
notifications_configuration = var.notifications_configuration
}
For invoking the module remotely, set the module source attribute to the notifications module folder in this repository, as shown:
module "notifications" {
source = "github.com/oracle-quickstart/terraform-oci-cis-landing-zone-observability/notifications"
notifications_configuration = var.notifications_configuration
}
For referring to a specific module version, append ref=<version> to the source attribute value, as in:
source = "github.com/oracle-quickstart/terraform-oci-cis-landing-zone-observability//notifications?ref=v0.1.0"
In this module, notifications are defined using the notifications_configuration object, that supports the following attributes:
- default_compartment_id: the default compartment for all resources managed by this module. It can be overriden by compartment_id attribute in each resource. This attribute is overloaded. It can be assigned either a literal OCID or a reference (a key) to an OCID.
- default_defined_tags: the default defined tags that are applied to all resources managed by this module. It can be overriden by defined_tags attribute in each resource.
- default_freeform_tags: the default freeform tags that are applied to all resources managed by this module. It can be overriden by freeform_tags attribute in each resource.
- topics: define the notification topics and associated subscriptions.
Within notifications_configuration, use the topics attribute to define the topics and subscriptions managed by this module. Each topic is defined as an object whose key must be unique and must not be changed once defined. As a convention, use uppercase strings for the keys.
The topics attribute supports the following attributes:
- compartment_id: the compartment where the topic is created. default_compartment_id is used if undefined. This attribute is overloaded. It can be assigned either a literal OCID or a reference (a key) to an OCID.
- name: the topic name.
- description: the topic description. It defaults to topic name- if undefined.
- subscriptions: the topic subscriptions, supporting the following attributes:
- protocol: The subscription protocol. Valid values (case insensitive): EMAIL, CUSTOM_HTTPS, PAGERDUTY, SLACK, ORACLE_FUNCTIONS, SMS.
- values: the list of endpoint values, specific to each protocol.
- defined_tags: the subscription defined_tags. The topic defined_tags is used if undefined.
- freeform_tags: the subscription freeform_tags. The topic freeform_tags is used if undefined.
- defined_tags: the topic defined_tags. default_defined_tags is used if undefined.
- freeform_tags: the topic freeform_tags. default_freeform_tags is used if undefined.
An optional feature, external dependencies are resources managed elsewhere that resources managed by this module may depend on. The following dependencies are supported:
- compartments_dependency: A map of objects containing the externally managed compartments this module may depend on. All map objects must have the same type and must contain at least an id attribute with the compartment OCID.
The following snippet defines two topics in different compartments defined by compartment_id values. The first topic (NETWORK-TOPIC) is for network related notifications. It is subscribed by two email addresses. The second topic (SECURITY-TOPIC) is for security related notifications. It is subscribed by one SMS number.
Supported protocols are EMAIL, CUSTOM_HTTPS, PAGERDUTY, SLACK, ORACLE_FUNCTIONS, SMS. Look at https://docs.oracle.com/en-us/iaas/Content/Notification/Tasks/create-subscription.htm for details on protocol requirements.
notifications_configuration = {
default_compartment_id = null
topics = {
NETWORK-TOPIC = {
compartment_id = "ocid1.compartment.oc1..aaaaaa...tgr"
name = "cislz-network-topic"
subscriptions = [{
protocol = "EMAIL"
values = ["[email protected]","[email protected]"]
}]
}
SECURITY-TOPIC = {
compartment_id = "ocid1.compartment.oc1..aaaaaa...xuq"
name = "cislz-security-topic"
subscriptions = [{
protocol = "SMS"
values = ["+19999999999"]
}]
}
}
}
None.