Deepak Ingale 1
ServiceNow Employee

Disclaimer: The views in this post are my own and do not represent ServiceNow, Inc. The setup was built and tested in a personal lab using non-production resources and is shared for reference only. Actual implementation should align with your organization's enterprise standards, including security policies, best practices, and change processes. Your environment and ServiceNow release may differ, so check the official documentation before applying anything. Shared as-is, without warranty.

 

Credential-less AWS Cloud Discovery with ServiceNow

 

In this series, we are going to cover three articles, first two to setup credential-less AWS Cloud Discovery, and in the last article, we are going to extend current setup to enable Kubernetes Discovery.

 

Contents

  • Article 1: Architecture and AWS IAM setup [AWS setup]
  • Article 2: ServiceNow configuration, discovery [ServiceNow setup]
  • Article 2: Kubernetes Cluster, node group setup and discovery. [AWS and ServiceNow setup]

 

Note: All account IDs, instance IDs, instance URLs, and download links in this series are shown as placeholders in angle brackets, such as <ACCESSOR-ACCOUNT-ID>. Replace them with your own values in your private environment only.

 

ServiceNow: Architecture and AWS IAM Setup

 

Traditional AWS discovery in ServiceNow stores long-lived access keys in the instance. This series shows a different approach: a MID server running on EC2 discovers AWS resources using IAM roles only, so no access keys are created or stored in ServiceNow.

 

Note: This series documents a personal lab built in a personal AWS environment. Test everything in a non-production environment before you apply it to a real customer.

 

The design

 

The setup uses three account roles:

 

  • Accessor account: Hosts the MID server on an EC2 instance. Its instance role is the only identity that makes AWS API calls.
  • Management account: Holds a read-only discovery role that trusts the accessor's instance role directly.
  • Member accounts: Each holds a read-only discovery role that trusts the accessor's instance role directly. There are two access paths, and both start at the accessor:

 

 

DeepakIngale1_0-1795966448205.png

 

 

The important detail is what does not happen. Member accounts are never reached through the management account. The management role is not allowed to assume member roles, and member roles don't trust the management account's OrganizationAccountAccessRole. Each account is a separate, direct trust relationship from the accessor.

 

Prerequisites

  • An AWS Organization with a management account and one or more member accounts.
  • A ServiceNow instance with the Discovery and Cloud Discovery (AWS) plugins active.
  • Permission to deploy CloudFormation stacks in every account.
  • One AWS region, chosen once and used for all stacks.
  • For my setup, I used total 4 AWS accounts namely management, mid-accessor, member-1 and member-2.

 

Step 0 : Understanding the setup architecture.

We are going to use section 2.4.2 highlighted in article for our lab.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB2184482#Model4Role

 

Step 1: Download the CloudFormation templates

Download the templates from the KB article: Please refer section 8 for our CFT templates. https://support.servicenow.com/kb?sys_kb_id=b8f32daf934a6a10def533527cba1018&id=kb_article_view

 

You need three files:

  • EC2InstanceRole.yml, deployed in the accessor account.
  • CreateManagementDiscoveryAccessRole.yml, deployed in the management account.
  • CreateSnowAwsCloudDiscoveryPatternsRoleInMemberAccount.yml, deployed in each member

account, and optionally in the accessor account for self-discovery.

 

Read each template's Parameters and Conditions sections before deploying.

 

Step 2: Deploy the accessor stack

 

In the accessor account, go to CloudFormation > Create stack > Upload a template file and select

EC2InstanceRole.yml. Use these parameters:

 

DeepakIngale1_1-1795966448207.png

 

 

Acknowledge the IAM capabilities checkbox and submit. When the stack reaches CREATE_COMPLETE, open the Outputs tab and copy the RoleArn value.

 

Its format is arn:aws:iam::<ACCESSOR-ACCOUNT-ID>:role/SnowEc2InstanceDiscoveryRole. You need it for the next two stacks. What this stack creates:

 

  • The instance role SnowEc2InstanceDiscoveryRole, with an inline policy that allows AssumeRole only on the management and member discovery role names.
  • The managed policy EC2DiscoveryManagedPolicy, which is read-only and attached to the instance role.
  • An instance profile named SnowEc2InstanceDiscoveryRole-profile, which the EC2 instance uses at launch.

 

Screenshot below is taken from my aws account, which acts as “accessor” account where mid server instance is installed [EC2 Instance]

 

We can click on each of the stack name, once done, it will showcase all the resources deployed with this stack

 

DeepakIngale1_2-1795966448218.png

 

 

Screenshot of IAM role which gets created via CFT template.

 

DeepakIngale1_3-1795966448223.png

 

 

DeepakIngale1_4-1795966448229.png

 

 

Step 3: Deploy the management stack

 

Switch to the management account and upload CreateManagementDiscoveryAccessRole.yml. Use

these parameters:

 

DeepakIngale1_5-1795966448232.png

 

The management role's trust policy allows only the accessor's instance role:

DeepakIngale1_6-1795966448234.png

 

Step 4: Deploy the member stacks

 

DeepakIngale1_7-1795966448236.png

 

Screenshot below is taken from my aws account, which acts as “member” account. This is one of many accounts where actual AWS resources are running, which we need to discover.

DeepakIngale1_8-1795966448241.png

 

DeepakIngale1_9-1795966448247.png

Repeat this step in each member account, with the same template and parameters:

Each member role trusts only the accessor's instance role.

 

To let the accessor discover its own resources, deploy the same member template in the accessor account, with the same parameters.

 

Step 5: Verify the trust paths

 

Before you configure ServiceNow, test each path from the MID instance. Connect to the instance

then run the commands below. Replace each placeholder with a bare 12-digit account ID,

without angle brackets.

 

DeepakIngale1_11-1795966495656.png

 

Each assume-role command should return a Credentials block. Don't paste that output anywhere. The values are temporary, but they still grant access until they expire.

 

In the next article, we are going to make necessary changes in ServiceNow to run successful Cloud Discovery.

Version history
Last update:
2 hours ago
Updated by:
Contributors