Automation – Terraform & ServiceNow

The possibilities to automate and streamline work is vast and the opportunities grow as software and technology continues to improve.

One area that can bring a lot of value and effort saved, is the management of Data Centres and Company Infrastructure.

A strategy that’s available, is to use Terraform and ServiceNow. This will allow companies to manage the infrastructure and also link it directly to the Service Management processes helping to run the organisation.

What is Terraform?

Terraform is an infrastructure-as-code-software by HashiCorp.
It allows users to define  Data Centre infrastructure in a high-level configuration language, from which it can create an execution plan to build the infrastructure such as OpenStack or in service providers such as –
  •  AWS
  • IBM Cloud (Bluemix)
  • Google Cloud Platform
  • Linode
  • Microsoft Azure
  • Oracle Cloud Infrastructure
  • VMware vSphere.

Infrastructure is defined in an HCL Terraform syntax or JSON format.

Features of Terraform:

Infrastructure as Code

Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your data centre to be versioned and treated as you would any other code.

Additionally, infrastructure can be shared and re-used.

Execution Plans

Terraform has a „planning” step where it generates an execution plan. The execution plan shows what Terraform will do when you call ‚apply’.

This lets you avoid any surprises when Terraform manipulates infrastructure.

Resource Graph

Terraform builds a graph of all your resources, and parallelizes the creation and modification of any non-dependent resources.

Terraform builds infrastructure as efficiently as possible, and operators get insight into dependencies in their infrastructure.

Change Automation

Complex changesets can be applied to your infrastructure with minimal human interaction.

With the previously mentioned execution plan
and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors.

Use Cases of Terraform

  • Heroku App Setup
  • Software Demos
  • Self-Service Clusters
  • Multi-Tier Applications
  • Software Defined Networking
  • Resource Schedulers
  • Disposable Environments
  • Multi-Cloud Deployment

Terraform Tree Structure

Terraform & ServiceNow

TerraSnow Enterprise

Let’s think about automation end-to-end. How can we use ServiceNow to automatically manage Data Centres and Company Infrastructure?

One example of harnessing Terraform and ServiceNow is the use of TerraSnow, an application provided as an open source project.

This enables the deployment of AWS resources from ServiceNow via Terraform Enterprise.

TerraSnow Enterprise is a collection of scripts that enables the deployment of Terraform resources from a ServiceNow instance via Terraform Enterprise.

It was designed to simplify cloud resource consumption at the user level and to operate within a multi-tenant AWS environment.

This solution contains a terraform template to deploy a Ngnix reverse proxied, Flask based endpoint, that handles Gitlab Tag and Push events by creating a ServiceNow Terraform Module Catalog Item.

The solution aims to provide easy management of company infrastructure and includes the collection of events in the ticketing system.

Using such a solution would allow organisations to build, upgrade, manage and improve their environment form one point!

Requirements for the TerraSnow Solution:

  • Admin access to the target AWS account
  • The latest version of Terraform installed on the machine from which the TerraSnow Instance template will be deployed
  • Pre-configured Gitlab instance
  • Pre-configured ServiceNow Instance
  • Web console access to Terraform Enterprise
  • MID Server

Installation Steps for Deploying TerraSnow

  • Configure ServiceNow
  • Create the TerraSnow Configuration File
  • Configure/Deploy your MID Server
  • Install the TerraSnow Scoped Application
  • Associate the TerraSnow application with your MID server
  • Create the TerraSnow API User
  • Collect the required sys_ids
  • Configure Terraform Enterprise
  • Upload the TerraSnow Configuration file to S3
  • Deploy the TerraSnow Instance
  • Proceed to the usage section to create your first terraform catalogue item

Setup of the TerraSnow Solution

  1. Clone the TerraSnow Enterprise repo to your workstation.
  2. Create a file called config.ini in the root of the Terrasnow-enterprise directory.
    See the Configuration File section of this document for this file’s structure.
  3. Fork the TerraSnow Enterprise Scoped Application project into a personal repo

Creating the TerraSnow Configuration File Info Table for TerraSnow

For more information and resources please use the following links  –

  1. https://www.terraform.io/
  2. https://terrasnow-enterprise.readthedocs.io/en/latest/