» Example Customizations

» Creating a Catalog Item with Pinned Variables

This example use case creates a Terraform catalog item for resources that limits user input to certain variables.

» Create Service Catalog Item

  1. Enter the ServiceNow Studio.
  2. Click "Create Application File" to raise a dialog box of options.
  3. In the dialog, navigate to the "Service Catalog" section, select "Catalog Item", and click the "Create" button.
  4. Name the new catalog item. (The rest of this example assumes an item named Example With Pinned Variables.)
  5. Select Catalogs: "Terraform Catalog" > Select Categories: "Terraform Resources".
  6. Add any other descriptions you may want.
  7. Click "Submit".

screenshot: ServiceNow integration create catalog item

» Create Variable Set

  1. Click "Create Application File" to raise a dialog box of options.
  2. In the dialog, navigate to the "Service Catalog" section, select "Variable Set", and click the "Create" button.
  3. Name your variable set. (The rest of this example assumes a set named Example Pinned Variables, with a default "Internal Name" of example_pinned_variables.)
  4. Click "Submit".
  5. Under the "Variables" tab click "New".
    1. Create your variable:
    2. In this example we will create a field called tf_var_pet_name_length that will be for a Terraform variable that determines the number of words to use for the pet server name.
      • Question: Pet Name Length
      • Name: tf_var_pet_name_length
      • tf_var_ tells the Terraform ServiceNow SDK that this is a Terraform variable.
    3. Repeat variable creation as necessary for your use case.
    4. Click "Submit".

screenshot: ServiceNow integration create catalog item

» Add Variable Set to Catalog Item

  1. Go back to your Catalog Item.
  2. Under the "Variable Sets" tab, click "New".
  3. Search for and select the variable set you created (Example Pinned Variables).
  4. Click "Submit".

» Create Custom Workflow

This example uses the "Example With Pinned Variables" workflow, which is one of the example workflows included with the integration.

In the ServiceNow Studio:

  1. Navigate to "Workflow" > "Workflow" > "Example With Pinned Variables".
  2. Double click on the "Run Script" item.
  3. Copy the script code from the editor.
  4. Close the "Run Script" and "Workflow" windows.
  5. Create a new custom workflow, by clicking "Create Application File" and choosing "Workflow".
    • Name: Example Pinned Variables (replace with your custom workflow name)
    • Table: Requested Item [sc_req_item] and Click "Submit"
  6. Add a "Run Script" item to the workflow, by navigating to the "Core" tab and selecting "Utilities" > "Run Script".

    • Name: Example Workflow Pinned Variables
    • Script:

      • Paste in the code copied from the "Provision Resources with Variables" workflow, and change the following lines:

          // ** Custom Variables **
          var VAR_SET_NAME = "example_pinned_variables";
          var VCS_REPO     = "ORG_NAME/REPO_NAME";
        
  7. Click "Submit"

  8. Ensure that the ServiceNow Run Script is part of the workflow. (The summary of the workflow should look like "Begin" > "Run Script" > "End".)

  9. Click the menu at the top left and select "Publish"

» Set The Workflow for Catalog Item

In the ServiceNow Studio:

  1. Select the "Example with Pinned Variables" catalog item. ("Service Catalog" > "Catalog Item" > "Example With Pinned Variables")
  2. Select the "Process Engine" tab.
  3. Set the workflow field by searching for the "Example Pinned Variables" workflow and clicking "Update".

» Test the Catalog Item

The new item should be available in the Terraform Service Catalog. Once the new catalog item is confirmed to work, you can customize as needed.