The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Narsing1
Mega Sage

Usage of an AWS Tag with regards to Servicenow

Tag is a metadata to your AWS resources consisting of a key value pair.  It helps you to manage, identify, organize your resources in the organization.  These tags can be used to update/insert records in the Servicenow Tables.

Goal of this Article

  • To see how the AWS Custom tags can be updated in different Servicenow Tables
  • To see whether the Tags can be updated without AWS Alert Configuration.
  • To restrict the SNS Service to send only EC2 related updates to make sure it will not dump anything and everything into sn_cmp_cloud_event Table

How Many ways Servicenow Table can be updated based on Tags

  • AWS SNS (Simple Notification Service). A complete setup guide can be find here.  
  • With CMDB Key Value Table (This can store all the Tag values for a CI even though you don’t configure the Simple Notification Service)

Precautions when you configure Simple Notification Service

  • While you do the AWS configure, choose what resource information you would like to take.  In this case, we need to take only EC2 Instance information.  So need to configure like this
    • Go to AWS Console → Config → Settings – > Edit → Make sure you select only “AWS EC2 Instance” in the Resourse Type

find_real_file.png

find_real_file.png

find_real_file.png

Example

I have one EC2 Instance and I would like to update the “Business Unit” of the VM in the Servicenow VM Instance Table (In normal cloud discovery, this field value will not be updated). Now, we will see how it can be updated via AWS Tags.

  • On the AWS Console → Go to EC2 Instance → Tags Tab → Click on “Manage Tags”

find_real_file.png

find_real_file.png

If you configure the SNS, once the above tags are updated, it creates an event in the Cloud Event Table as below. The Payload field from this table contains what values are updated along with its previous value.

find_real_file.png

find_real_file.png

And it also updates the cmdb_key_value table like this

find_real_file.png

Now, we are going write a Business Rule to update the table

find_real_file.png

find_real_file.png

(function executeRule(current, previous /*null when async*/ ) {

    //Find Business Service based on Key,Value with Correlation ID
    var gr = new GlideRecord("cmdb_ci_vm_instance");
	gr.addQuery("sys_id", current.configuration_item.toString());
	gr.query();
	if(gr.next()) {
		var bu = new GlideRecord("business_unit");
		bu.addQuery("name", current.value.toString());
		bu.query();
		if(bu.next()) {
			gr.business_unit = bu.sys_id.toString();
			gr.update();
		}
	}



})(current, previous);

find_real_file.png

Same way, you may write for updates/deletes using this table(cmdb_key_value).

Let me know your thoughts whether we have any other way to do Custom Tags update.

Version history
Last update:
‎07-22-2022 10:54 PM
Updated by: