Note:

Verify notifications for compute instances

Introduction

The Oracle Cloud Infrastructure Notifications service broadcasts messages to distributed components through a publish-subscribe pattern, delivering secure, highly reliable, low latency and durable messages for applications hosted on Oracle Cloud Infrastructure and externally.

The Notifications service enables you to set up 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.

Objectives

Verify notifications when a compute instance is launched and deleted.

Sign in to OCI Console and Configure Notification and Event

  1. Sign in to Oracle Cloud Infrastructure Console using your cloud tenant name, user name, and password.

  2. First we will create a Notification topic and subscribe to this topic. From the OCI services menu, click Notifications under Application Integration.

  3. Click Create Topic and fill out the dialog box:

    • Name: Provide a name.
    • Description: Provide a description.
  4. Click Create.

    Create Topic

  5. Once the topic state changes to Active, click the topic name. Click Create Subscription and fill out the dialog box:

    • PROTOCOL: Email.
    • EMAIL: Provide your email id.
  6. Click Create.

    Subscription details screen will be displayed with subscription status showing Pending.

  7. Check the email account you specified and click the verification link for this subscription. Switch back to OCI Console window and verify that the subscription status changed to Active. You may need to refresh your browser.

  8. You are now subscribed to a Notification topic. Next we will configure Events that will publish messages to this Notification topic.

  9. From the OCI services menu, under Application Integration, click Events Service.

  10. Click Create Rule. Fill out the dialog box:

    • DISPLAY NAME: Provide a name.
    • DESCRIPTION: Provide a description.

    Under Rule Conditions:

    • Ensure Event Type is selected.
    • SERVICE NAME: Compute.
    • EVENT TYPE: Choose these 4 types from the drop down menu: Instance-Launch Begin, Instance-Launch End, Instance-Terminate Begin, and Instance-Terminate End.

    Under Actions:

    • ACTION TYPE: Notifications.
    • NOTIFICATIONS COMPARTMENT: Select your compartment under List Scope in the left navigation pane.
    • TOPIC: Choose the topic created earlier.
  11. Click Create Rule.

    Rule Conditions

We have now configured Notification service and tied events to it with a specific compartment. When a new compute instance is launched or terminated, an email notification will be sent to the email address specified.

Create a Virtual Cloud Network

  1. From the OCI services menu, under Networking, click Virtual Cloud Networks. Select your current compartment under Networking, and click Start VCN Wizard.

    Note: Ensure that the correct compartment is selected under COMPARTMENT list.

  2. Click VCN with Internet Connectivity and click Start VCN Wizard.

  3. Fill out the dialog box and click Next:

    • VCN NAME: Provide a name
    • COMPARTMENT: Ensure your compartment is selected
    • VCN CIDR BLOCK: Provide a CIDR block (10.0.0.0/16)
    • PUBLIC SUBNET CIDR BLOCK: Provide a CIDR block (10.0.1.0/24)
    • PRIVATE SUBNET CIDR BLOCK: Provide a CIDR block (10.0.2.0/24)
  4. Verify all the information and click Create.

    This will create a VCN with following components: VCN, Public subnet, Private subnet, Internet gateway (IG), NAT gateway (NAT), and Service gateway (SG).

  5. Click View Virtual Cloud Network to display your VCN details.

Create a Compute Instance and Verify Notification

  1. From the OCI services menu, click Instances under Compute.

  2. Click Create Instance. Fill out the dialog box:

    • Name your instance: Enter a name.
    • Choose an operating system or image source: For the image, we recommend using the Latest Oracle Linux available.
    • Availability Domain: Select availability domain.
    • Instance Type: Select virtual machine.
    • Instance Shape: Select VM shape.

    Under Configure Networking:

    • Virtual cloud network compartment: Select your compartment.

    • Virtual cloud network: Choose the VCN.

    • Subnet Compartment: Choose your compartment.

    • Subnet: Choose the Public Subnet under Public Subnets.

    • Use network security groups to control traffic: Leave un-checked.

    • Assign a public IP address: Check this option.

      Assign a Public IP Address

    • Boot Volume: Leave the default

    • Add SSH Keys: Leave empty

  3. Click Create.

    Note: If a Service limit error is displayed, choose a different shape from VM.Standard2.1, VM.Standard.E2.1, VM.Standard1.1, VM.Standard.B1.1, OR choose a different AD.

  4. Switch to your email account and verify that an event indicating that the compute instance launch was received.

  5. Wait for the instance to be in Running state.

  6. Switch to your email account and verify that an event indicating that the compute instance create was received.

Delete the Resources

  1. Switch to the OCI Console window.

  2. If your compute instance is not displayed, from the OCI services menu, click Instances under Compute.

  3. Locate the first compute instance, click the Action icon, and then click Terminate.

    Terminate Button

  4. Make sure Permanently delete the attached Boot Volume is checked, and click Terminate Instance. Wait for the instance to fully terminate.

    Terminate Instance Button

  5. Switch to your email account and verify that an event indicating that the compute instance termination was received.

    Once the compute instance is fully terminated, another email notification will arrive.

  6. From the OCI services menu, click Virtual Cloud Networks under Networking. A list of all VCNs will appear.

  7. Locate your VCN, click the Action icon, and then click Terminate. Click Terminate All in the confirmation window. Click Close once the VCN is deleted.

    Terminate Button

  8. From the OCI services menu, under Application Integration, click Notifications. Click your topic name.

  9. Click Delete.

  10. From the OCI services menu, under Application Integration, click Event Service.

  11. Click your rule name and click Delete. In the dialog box, type DELETE and click Delete.

Acknowledgements

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.