terraform infrastructure from ServiceNow page title Setup Instructions ServiceNow Service Catalog Integration HCP Terraform Terraform ServiceNow Service Catalog Integration Setup Instructions Integration version v2 7 0 ServiceNow integration enables your users to order Terraform built

Answer:
---
page_title: Setup Instructions - ServiceNow Service Catalog Integration - HCP Terraform
description: >-
  ServiceNow integration enables your users to order Terraform-built
  infrastructure from ServiceNow.
---

# Terraform ServiceNow Service Catalog Integration Setup Instructions

-> **Integration version:**  v2.7.0

The Terraform ServiceNow Service Catalog integration enables your end-users to
provision self-serve infrastructure via ServiceNow. By connecting ServiceNow to
HCP Terraform, this integration lets ServiceNow users order Service Items,
create workspaces, and perform Terraform runs using prepared Terraform
configurations hosted in VCS repositories or as [no-code
modules](/terraform/cloud-docs/no-code-provisioning/module-design) for
self-service provisioning.

<!-- BEGIN: TFC:only name:pnp-callout -->
@include 'tfc-package-callouts/servicenow-catalog.mdx'
<!-- END: TFC:only name:pnp-callout -->

## Summary of the Setup Process

The integration relies on Terraform ServiceNow Catalog integration software
installed within your ServiceNow instance. Installing and configuring this
integration requires administration in both ServiceNow and HCP Terraform.
Since administrators of these services within your organization are not
necessarily the same person, this documentation refers to a **ServiceNow Admin**
and a **Terraform Admin**.

First, the Terraform Admin configures your HCP Terraform organization with a
dedicated team for the ServiceNow integration, and obtains a team API token for
that team. The Terraform Admin provides the following to your ServiceNow admin:
* An Organization name
* A team API token
* The hostname of your HCP Terraform instance
* Any available no-code modules or version control repositories containing Terraform configurations
* Other required variables
token, the hostname of your HCP Terraform instance, and details about no-code
modules or version control repositories containing Terraform configurations and
required variables to the ServiceNow Admin.

Next, the ServiceNow Admin will install the Terraform ServiceNow Catalog
integration to your ServiceNow instance, and configure it using the team API
token and hostname.

Finally, the ServiceNow Admin will create a Service Catalog within ServiceNow
for the Terraform integration, and configure it using the version control
repositories or no-code modules, and variable definitions provided by the
Terraform Admin.

| ServiceNow Admin                                                             | Terraform Admin                                                                                |
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|                                                                              | Prepare an organization for use with the ServiceNow Catalog.                                                                               |
|                                                                              | Create a team that can manage workspaces in that organization.                                                                             |
|                                                                              | Create a team API token so the integration can use that team's permissions.                                                                |
|                                                                              | If using VCS repositories, retrieve the OAuth token IDs and repository identifiers that HCP Terraform uses to identify your VCS repositories. If using a no-code flow, [create a no-code ready module](/terraform/cloud-docs/no-code-provisioning/provisioning) in your organization's private registry. Learn more in [Configure VCS Repositories or No-Code Modules](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config#configure-vcs-repositories-or-no-code-modules).|
|                                                                              | Provide the API token, OAuth token ID, repository identifiers, variable definitions, and HCP Terraform hostname to the ServiceNow Admin. |
| Install the Terraform integration application from the ServiceNow App Store. |                                                                                |
| Connect the integration application with HCP Terraform.                    |                                                                                |
| Add the Terraform Service Catalog to ServiceNow.                             |                                                                                |
| If you are using the VCS flow, configure the VCS repositories in ServiceNow.         |                                                                                |
| Configure variable sets for use with the VCS repositories or no-code modules.|                                                                                |

Once these steps are complete, self-serve infrastructure will be available
through the ServiceNow Catalog. HCP Terraform will provision and manage
requested infrastructure and report the status back to ServiceNow.

## Prerequisites

To start using Terraform with the ServiceNow Catalog Integration, you must have:

- An administrator account on a Terraform Enterprise instance or within a
  HCP Terraform organization.
- An administrator account on your ServiceNow instance.
- If you are using the VCS flow, one or more [supported version control
  systems](/terraform/cloud-docs/vcs#supported-vcs-providers) (VCSs) with read
  access to repositories with Terraform configurations.
- If you are using no-code provisioning, one or more [no-code modules](/terraform/cloud-docs/no-code-provisioning/provisioning) created in
  your organization's private registry. Refer to the [no-code module
configuration](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config#no-code-module-configuration)
for information about using no-code modules with the ServiceNow Service Catalog
for Terraform.

You can use this integration on the following ServiceNow server versions:

- Utah
- Vancouver
- Washington DC
- Xanadu

It requires the following ServiceNow plugins as dependencies:

- Flow Designer support for the Service Catalog (`com.glideapp.servicecatalog.flow_designer`)
- ServiceNow IntegrationHub Action Step - Script (`com.glide.hub.action_step.script`)
- ServiceNow IntegrationHub Action Step - REST (`com.glide.hub.action_step.rest`)

-> **Note:** Dependent plugins are installed on your ServiceNow instance automatically when the app is downloaded from the ServiceNow Store.

## Configure HCP Terraform

Before installing the ServiceNow integration, the Terraform Admin will need to
perform the following steps to configure and gather information from HCP
Terraform.

1. Either [create an
   organization](/terraform/cloud-docs/users-teams-organizations/organizations#creating-organizations)
   or choose an existing organization where ServiceNow will create new
   workspaces.
   **Save the organization name for later.**
2. [Create a team](/terraform/cloud-docs/users-teams-organizations/teams) for that
   organization called "ServiceNow", and ensure that it has [permission to
   manage
   workspaces](/terraform/cloud-docs/users-teams-organizations/permissions#manage-all-workspaces).
   You do not need to add any users to this team.
   [permissions-citation]: #intentionally-unused---keep-for-maintainers
3. On the "ServiceNow" team's settings page, generate a [team API
   token](/terraform/cloud-docs/users-teams-organizations/api-tokens#team-api-tokens).
   **Save the team API token for later.**
4. If you are using the [VCS flow](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config#vcs-configuration):
    1. Ensure your Terraform organization is [connected to a VCS provider](/terraform/cloud-docs/vcs). Repositories that are connectable to HCP Terraform workspaces can also be used as workspace templates in the ServiceNow integration.
    2. On your organization's VCS provider settings page (**Settings** > **VCS Providers**), find the OAuth Token ID for the VCS provider(s) that you intend to use with the ServiceNow integration. HCP Terraform uses the OAuth token ID to identify and authorize the VCS provider. **Save the OAuth token ID for later.**
    3. Identify the VCS repositories in the VCS provider containing Terraform configurations that the ServiceNow Terraform integration will deploy. Take note of any Terraform or environment variables used by the repositories you select. Save the Terraform and environment variables for later.
5. If using the [no-code flow](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config#no-code-module-configuration), create one or more no-code modules in the private registry of your HCP Terraform. **Save the no-code module names for later.**
6. Provide the following information to the ServiceNow Admin:
    * The organization name
    * The team API token
    * The hostname of your Terraform Enterprise instance, or of HCP Terraform. The hostname of HCP Terraform is `app.terraform.io`.
    * The no-code module name(s) or the OAuth token ID(s) of your VCS provider(s), and the repository identifier for each VCS repository containing Terraform configurations that will be used by the integration.
    * Any Terraform or environment variables required by the configurations in the
   given VCS repositories.

-> **Note:** Repository identifiers are determined by your VCS provider; they
typically use a format like `<ORGANIZATION>/<REPO_NAME>` or
`<PROJECT_KEY>/<REPO_NAME>`. Azure DevOps repositories use the format
`<ORGANIZATION>/<PROJECT>/_git/<REPO_NAME>`. A GitHub repository hosted at
`https://github.com/exampleorg/examplerepo/` would have the repository
identifier `exampleorg/examplerepo`.

[permissions-citation]: #intentionally-unused---keep-for-maintainers

For instance, if you are configuring this integration for your company, `Example
Corp`, using two GitHub repositories, you would share values like the following
with the ServiceNow Admin.

```markdown
Terraform Enterprise Organization Name: `ServiceNowExampleOrg`

Team API Token: `q2uPExampleELkQ.atlasv1.A7jGHmvufExampleTeamAPITokenimVYxwunJk0xD8ObVol054`

Terraform Enterprise Hostname: `terraform.corp.example`

OAuth Token ID (GitHub org: example-corp): `ot-DhjEXAMPLELVtFA`
  - Repository ID (Developer Environment): `example-corp/developer-repo`
    - Environment variables:
      - `AWS_ACCESS_KEY_ID=AKIAEXAMPLEKEY`
      - `AWS_SECRET_ACCESS_KEY=ZB0ExampleSecretAccessKeyGjUiJh`
      - `AWS_DEFAULT_REGION=us-west-2`
    - Terraform variables:
      - `instance_type=t2.medium`
  - Repository ID (Testing Environment): `example-corp/testing-repo`
    - Environment variables:
      - `AWS_ACCESS_KEY_ID=AKIAEXAMPLEKEY`
      - `AWS_SECRET_ACCESS_KEY=ZB0ExampleSecretAccessKeyGjUiJh`
      - `AWS_DEFAULT_REGION=us-west-2`
    - Terraform variables:
      - `instance_type=t2.large`
```

## Install the ServiceNow Integration

Before beginning setup, the ServiceNow Admin must install the Terraform
ServiceNow Catalog integration software.

This can be added to your ServiceNow instance from the [ServiceNow
Store](https://store.servicenow.com/sn_appstore_store.do). Search for the "Terraform" integration,
published by "HashiCorp Inc".

![Screenshot: ServiceNow Store Page](/img/docs/service-now-store.png "Screenshot of the ServiceNow Store listing for the Terraform Integration")

## Connect ServiceNow to HCP Terraform

-> **ServiceNow Roles:** `admin` or `x_terraform.config_user`

Once the integration is installed, the ServiceNow Admin can connect your
ServiceNow instance to HCP Terraform. Before you begin, you will need the
information described in the "Configure HCP Terraform" section from your
Terraform Admin.

Once you have this information, connect ServiceNow to HCP Terraform with
the following steps.

1. Navigate to your ServiceNow Service Management Screen.
1. Using the left-hand navigation, open the configuration table for the
   integration to manage the HCP Terraform connection.
   - Terraform > Configs
1. Click on "New" to create a new HCP Terraform connection.
   - Set Org Name to the HCP Terraform organization name.
   - Click on the "Lock" icon to set Hostname to the hostname of your Terraform
     Enterprise instance. If you are using the SaaS version of HCP Terraform,
     the hostname is `https://app.terraform.io`. Be sure to include "https://"
     before the hostname.
   - Set API Team Token to the HCP Terraform team API token.
   - (Optional) To use the [MID Server](https://docs.servicenow.com/csh?topicname=mid-server-landing.html&version=latest),
     select the checkbox and type the `name` in the `MID Server Name` field.
1. Click "Submit".

![Screenshot: ServiceNow Terraform Config](/img/docs/service-now-updated-config.png "Screenshot of the ServiceNow Terraform Config New Record page")

## Create and Populate a Service Catalog

Now that you have connected ServiceNow to HCP Terraform, you are ready to
create a Service Catalog using the VCS repositories or no-code modules provided
by the Terraform Admin.

Navigate to the [Service Catalog documentation](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config) to
begin. You can also refer to this documentation whenever you need to add or
update request items.

### ServiceNow Developer Reference

ServiceNow developers who wish to customize the Terraform integration can refer
to the [developer documentation](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/developer-reference).

### ServiceNow Administrator's Guide.

Refer to the [ServiceNow Administrator documentation](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/admin-guide) for
information about configuring the integration.

### Example Customizations

Once the ServiceNow integration is installed, you can consult the [example
customizations documentation](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/example-customizations).

page title  Setup Instructions   ServiceNow Service Catalog Integration   HCP Terraform description       ServiceNow integration enables your users to order Terraform built   infrastructure from ServiceNow         Terraform ServiceNow Service Catalog Integration Setup Instructions       Integration version     v2 7 0  The Terraform ServiceNow Service Catalog integration enables your end users to provision self serve infrastructure via ServiceNow  By connecting ServiceNow to HCP Terraform  this integration lets ServiceNow users order Service Items  create workspaces  and perform Terraform runs using prepared Terraform configurations hosted in VCS repositories or as  no code modules   terraform cloud docs no code provisioning module design  for self service provisioning         BEGIN  TFC only name pnp callout      include  tfc package callouts servicenow catalog mdx       END  TFC only name pnp callout         Summary of the Setup Process  The integration relies on Terraform ServiceNow Catalog integration software installed within your ServiceNow instance  Installing and configuring this integration requires administration in both ServiceNow and HCP Terraform  Since administrators of these services within your organization are not necessarily the same person  this documentation refers to a   ServiceNow Admin   and a   Terraform Admin     First  the Terraform Admin configures your HCP Terraform organization with a dedicated team for the ServiceNow integration  and obtains a team API token for that team  The Terraform Admin provides the following to your ServiceNow admin    An Organization name   A team API token   The hostname of your HCP Terraform instance   Any available no code modules or version control repositories containing Terraform configurations    Other required variables token  the hostname of your HCP Terraform instance  and details about no code modules or version control repositories containing Terraform configurations and required variables to the ServiceNow Admin   Next  the ServiceNow Admin will install the Terraform ServiceNow Catalog integration to your ServiceNow instance  and configure it using the team API token and hostname   Finally  the ServiceNow Admin will create a Service Catalog within ServiceNow for the Terraform integration  and configure it using the version control repositories or no code modules  and variable definitions provided by the Terraform Admin     ServiceNow Admin                                                               Terraform Admin                                                                                Prepare an organization for use with the ServiceNow Catalog                                                                                Create a team that can manage workspaces in that organization                                                                                Create a team API token so the integration can use that team s permissions                                                                                If using VCS repositories  retrieve the OAuth token IDs and repository identifiers that HCP Terraform uses to identify your VCS repositories  If using a no code flow   create a no code ready module   terraform cloud docs no code provisioning provisioning  in your organization s private registry  Learn more in  Configure VCS Repositories or No Code Modules   terraform cloud docs integrations service now service catalog terraform service catalog config configure vcs repositories or no code modules                                                                                Provide the API token  OAuth token ID  repository identifiers  variable definitions  and HCP Terraform hostname to the ServiceNow Admin      Install the Terraform integration application from the ServiceNow App Store                                                                                Connect the integration application with HCP Terraform                                                                                Add the Terraform Service Catalog to ServiceNow                                                                                If you are using the VCS flow  configure the VCS repositories in ServiceNow                                                                                Configure variable sets for use with the VCS repositories or no code modules                                                                                Once these steps are complete  self serve infrastructure will be available through the ServiceNow Catalog  HCP Terraform will provision and manage requested infrastructure and report the status back to ServiceNow      Prerequisites  To start using Terraform with the ServiceNow Catalog Integration  you must have     An administrator account on a Terraform Enterprise instance or within a   HCP Terraform organization    An administrator account on your ServiceNow instance    If you are using the VCS flow  one or more  supported version control   systems   terraform cloud docs vcs supported vcs providers   VCSs  with read   access to repositories with Terraform configurations    If you are using no code provisioning  one or more  no code modules   terraform cloud docs no code provisioning provisioning  created in   your organization s private registry  Refer to the  no code module configuration   terraform cloud docs integrations service now service catalog terraform service catalog config no code module configuration  for information about using no code modules with the ServiceNow Service Catalog for Terraform   You can use this integration on the following ServiceNow server versions     Utah   Vancouver   Washington DC   Xanadu  It requires the following ServiceNow plugins as dependencies     Flow Designer support for the Service Catalog   com glideapp servicecatalog flow designer     ServiceNow IntegrationHub Action Step   Script   com glide hub action step script     ServiceNow IntegrationHub Action Step   REST   com glide hub action step rest         Note    Dependent plugins are installed on your ServiceNow instance automatically when the app is downloaded from the ServiceNow Store      Configure HCP Terraform  Before installing the ServiceNow integration  the Terraform Admin will need to perform the following steps to configure and gather information from HCP Terraform   1  Either  create an    organization   terraform cloud docs users teams organizations organizations creating organizations     or choose an existing organization where ServiceNow will create new    workspaces       Save the organization name for later    2   Create a team   terraform cloud docs users teams organizations teams  for that    organization called  ServiceNow   and ensure that it has  permission to    manage    workspaces   terraform cloud docs users teams organizations permissions manage all workspaces      You do not need to add any users to this team      permissions citation    intentionally unused   keep for maintainers 3  On the  ServiceNow  team s settings page  generate a  team API    token   terraform cloud docs users teams organizations api tokens team api tokens        Save the team API token for later    4  If you are using the  VCS flow   terraform cloud docs integrations service now service catalog terraform service catalog config vcs configuration        1  Ensure your Terraform organization is  connected to a VCS provider   terraform cloud docs vcs   Repositories that are connectable to HCP Terraform workspaces can also be used as workspace templates in the ServiceNow integration      2  On your organization s VCS provider settings page    Settings       VCS Providers     find the OAuth Token ID for the VCS provider s  that you intend to use with the ServiceNow integration  HCP Terraform uses the OAuth token ID to identify and authorize the VCS provider    Save the OAuth token ID for later        3  Identify the VCS repositories in the VCS provider containing Terraform configurations that the ServiceNow Terraform integration will deploy  Take note of any Terraform or environment variables used by the repositories you select  Save the Terraform and environment variables for later  5  If using the  no code flow   terraform cloud docs integrations service now service catalog terraform service catalog config no code module configuration   create one or more no code modules in the private registry of your HCP Terraform    Save the no code module names for later    6  Provide the following information to the ServiceNow Admin        The organization name        The team API token       The hostname of your Terraform Enterprise instance  or of HCP Terraform  The hostname of HCP Terraform is  app terraform io         The no code module name s  or the OAuth token ID s  of your VCS provider s   and the repository identifier for each VCS repository containing Terraform configurations that will be used by the integration        Any Terraform or environment variables required by the configurations in the    given VCS repositories        Note    Repository identifiers are determined by your VCS provider  they typically use a format like   ORGANIZATION   REPO NAME   or   PROJECT KEY   REPO NAME    Azure DevOps repositories use the format   ORGANIZATION   PROJECT   git  REPO NAME    A GitHub repository hosted at  https   github com exampleorg examplerepo   would have the repository identifier  exampleorg examplerepo     permissions citation    intentionally unused   keep for maintainers  For instance  if you are configuring this integration for your company   Example Corp   using two GitHub repositories  you would share values like the following with the ServiceNow Admin      markdown Terraform Enterprise Organization Name   ServiceNowExampleOrg   Team API Token   q2uPExampleELkQ atlasv1 A7jGHmvufExampleTeamAPITokenimVYxwunJk0xD8ObVol054   Terraform Enterprise Hostname   terraform corp example   OAuth Token ID  GitHub org  example corp    ot DhjEXAMPLELVtFA      Repository ID  Developer Environment    example corp developer repo        Environment variables           AWS ACCESS KEY ID AKIAEXAMPLEKEY           AWS SECRET ACCESS KEY ZB0ExampleSecretAccessKeyGjUiJh           AWS DEFAULT REGION us west 2        Terraform variables           instance type t2 medium      Repository ID  Testing Environment    example corp testing repo        Environment variables           AWS ACCESS KEY ID AKIAEXAMPLEKEY           AWS SECRET ACCESS KEY ZB0ExampleSecretAccessKeyGjUiJh           AWS DEFAULT REGION us west 2        Terraform variables           instance type t2 large          Install the ServiceNow Integration  Before beginning setup  the ServiceNow Admin must install the Terraform ServiceNow Catalog integration software   This can be added to your ServiceNow instance from the  ServiceNow Store  https   store servicenow com sn appstore store do   Search for the  Terraform  integration  published by  HashiCorp Inc      Screenshot  ServiceNow Store Page   img docs service now store png  Screenshot of the ServiceNow Store listing for the Terraform Integration       Connect ServiceNow to HCP Terraform       ServiceNow Roles     admin  or  x terraform config user   Once the integration is installed  the ServiceNow Admin can connect your ServiceNow instance to HCP Terraform  Before you begin  you will need the information described in the  Configure HCP Terraform  section from your Terraform Admin   Once you have this information  connect ServiceNow to HCP Terraform with the following steps   1  Navigate to your ServiceNow Service Management Screen  1  Using the left hand navigation  open the configuration table for the    integration to manage the HCP Terraform connection       Terraform   Configs 1  Click on  New  to create a new HCP Terraform connection       Set Org Name to the HCP Terraform organization name       Click on the  Lock  icon to set Hostname to the hostname of your Terraform      Enterprise instance  If you are using the SaaS version of HCP Terraform       the hostname is  https   app terraform io   Be sure to include  https          before the hostname       Set API Team Token to the HCP Terraform team API token        Optional  To use the  MID Server  https   docs servicenow com csh topicname mid server landing html version latest         select the checkbox and type the  name  in the  MID Server Name  field  1  Click  Submit      Screenshot  ServiceNow Terraform Config   img docs service now updated config png  Screenshot of the ServiceNow Terraform Config New Record page       Create and Populate a Service Catalog  Now that you have connected ServiceNow to HCP Terraform  you are ready to create a Service Catalog using the VCS repositories or no code modules provided by the Terraform Admin   Navigate to the  Service Catalog documentation   terraform cloud docs integrations service now service catalog terraform service catalog config  to begin  You can also refer to this documentation whenever you need to add or update request items       ServiceNow Developer Reference  ServiceNow developers who wish to customize the Terraform integration can refer to the  developer documentation   terraform cloud docs integrations service now service catalog terraform developer reference        ServiceNow Administrator s Guide   Refer to the  ServiceNow Administrator documentation   terraform cloud docs integrations service now service catalog terraform admin guide  for information about configuring the integration       Example Customizations  Once the ServiceNow integration is installed  you can consult the  example customizations documentation   terraform cloud docs integrations service now service catalog terraform example customizations


terraform page title Troubleshooting tips ServiceNow Service Catalog Integration HCP Terraform HCP Terraform ServiceNow Service Catalog Integration troubleshooting tips It also provides instructions on how to find and read logs to diagnose and resolve issues Troubleshooting tips for ServiceNow Service Catalog Integration This page offers troubleshooting tips for common issues with the ServiceNow Service Catalog Integration for HCP Terraform

Answer:
---
page_title: Troubleshooting tips - ServiceNow Service Catalog Integration - HCP Terraform
description: Troubleshooting tips for ServiceNow Service Catalog Integration.
---

# HCP Terraform ServiceNow Service Catalog Integration troubleshooting tips.

This page offers troubleshooting tips for common issues with the ServiceNow Service Catalog Integration for HCP Terraform.
It also provides instructions on how to find and read logs to diagnose and resolve issues.

## Find logs

Logs are crucial for diagnosing issues. You can find logs in ServiceNow in the following places:

### Workflow logs

To find workflow logs, click on the RITM number on a failed ticket to open the request item.
Scroll down to **Related Links > Workflow Context** and open the **Workflow Log** tab.

### Flow logs

To find flow logs, click on the RITM number on a failed ticket to open the request item.
Scroll down to **Related Links > Flow Context > Open Context Record** and open the **Flow engine log entries** tab.

### Application logs

To find application logs, navigate to **All > System Log > Application Logs.**
Set the **Application** filter to "Terraform".
Search for logs around the time your issue occurred. Some records include HTTP status codes and detailed error messages.

### Outbound requests

ServiceNow logs all outgoing API calls, including calls to HCP Terraform. To view the log of outbound requests, navigate  to **All > System Logs > Outbound HTTP Requests.**
To customize the table view, add columns like "URL," "URL Path," and "Application scope."
Logs from the Catalog app are marked with the `x_325709_terraform` scope.

## Enable email notifications

To enable email notifications and receive updates on your requested item tickets:

1. Log in to your ServiceNow instance as an administrator.
1. **Click System Properties > Email Properties**.
1. In the **Outbound Email Configuration** panel, select **Yes** next to the check-box with the email that ServiceNow should send notifications to.

To ensure you have relevant notifications configured in your instance:

1. Navigate to **System Notification > Email > Notifications.**
1. Search for "Request Opened" and "Request Item Commented" and ensure they are activated.

Reaching out to ServiceNow customer support if you run into any issues with the global configurations.out to ServiceNow customer support if you run into any issues with the global configurations.

## Common problems

This section details frequently encountered issues and how they can be resolved.

### Failure to create a workspace

If you order the "create a workspace" catalog item and  nothing happens in ServiceNow and HCP Terraform does not create a workspace then there are several possible reasons why:

Ensure your HCP Terraform token, hostname, and organization name is correct.

1. Make sure to use a **Team API Token**. This can be found in HCP Terraform under "API Tokens".
1. Ensure the team API token has the correct permissions.
1. Double-check your organization name by copying and pasting it from HCP Terraform or Terraform Enterprise.
1. Double-check your host name.
1. Make sure you created your team API token  in the same organization you are using
1. Test your configuration. First click **Update** to process any changes then **Test Config to make sure the connection is working.

Verify your VCS configuration.

1. The **Identifier** field should not have any spaces.  The ServiceNow Service Catalog Integration requires that you format repository names in the `username/repo_name` format.
1. The **Name** can be anything, but it is better to avoid special characters as per naming convention.
1. Double-check the OAuth token ID in your HCP Terraform/Terraform Enterprise settings. To retrieve your OAuth token ID, navigate to your HCP Terraform organization's settings page, then click **Provider** in the left navigation bar under **Version Control**.

### Failure to successfully order any catalog item

After placing an order for any catalog item, navigate to the comments section in the newly created RITM ticket.
The latest comment will contain a response from HCP Terraform.

### Frequency of comments and outputs

When you place an order in the  Terraform Catalog, ServiceNow submits and processes the order, then attaches  additional comments  to the order to indicate whether HCP Terraform successfully created the workspace.

By default, ServiceNow polls HCP Terraform every 5 minutes for the latest status of the Terraform run. ServiceNow does not show any comments until the next ping.

To configure ServiceNow to poll HCP Terraform more frequently:

1. Navigate to **All > Flow designer**.
1. Set the **Application** filter to **Terraform**.
1. Under the **Name** column click  **Worker Poll Run State**.
1. Click on the trigger and adjust the interval to your desired schedule.
1. Click **Done > Save > Activate** to save your changes.

### Using no-code modules feature

If ServiceNow fails to deploy a no-code module catalog item, verify the following:

1. Ensure that your HCP Terraform organization has an [HCP Plus tier](https://www.hashicorp.com/products/terraform/pricing) subscription.
1. Ensure the name you enter for your no-code module in the catalog user form matches the no-code module in HCP Terraform.
### Updating no-code workspaces

If the “update no-code workspace” catalog item returns the output message “No update has been made to the workspace”, then you have not upgraded your no-code module in HCP Terraform.

### Application Scope

If you are making customizations and you encounter unexpected issues, make sure to change the scope from **Global** to **Terraform** and recreate your customized items in the **Terraform scope**.
For additional instructions on customizations, refer to the [example customizations](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/example-customizations) documentation.

### MID server

If you are using a MID server in your configuration, check the connectivity by using the **Test Config** button on the configurations page.
Additionally, when ServiceNow provisions a MID server, navigate to **MID Servers > Servers** to check if the status is “up” and “validated”.

### Configuration

While the app allows multiple config entries, only one should be present as this can interfere with the functionality of the app

page title  Troubleshooting tips   ServiceNow Service Catalog Integration   HCP Terraform description  Troubleshooting tips for ServiceNow Service Catalog Integration         HCP Terraform ServiceNow Service Catalog Integration troubleshooting tips    This page offers troubleshooting tips for common issues with the ServiceNow Service Catalog Integration for HCP Terraform   It also provides instructions on how to find and read logs to diagnose and resolve issues      Find logs  Logs are crucial for diagnosing issues  You can find logs in ServiceNow in the following places       Workflow logs  To find workflow logs  click on the RITM number on a failed ticket to open the request item   Scroll down to   Related Links   Workflow Context   and open the   Workflow Log   tab        Flow logs  To find flow logs  click on the RITM number on a failed ticket to open the request item  Scroll down to   Related Links   Flow Context   Open Context Record   and open the   Flow engine log entries   tab        Application logs  To find application logs  navigate to   All   System Log   Application Logs    Set the   Application   filter to  Terraform    Search for logs around the time your issue occurred  Some records include HTTP status codes and detailed error messages       Outbound requests  ServiceNow logs all outgoing API calls  including calls to HCP Terraform  To view the log of outbound requests  navigate  to   All   System Logs   Outbound HTTP Requests     To customize the table view  add columns like  URL    URL Path   and  Application scope    Logs from the Catalog app are marked with the  x 325709 terraform  scope      Enable email notifications  To enable email notifications and receive updates on your requested item tickets   1  Log in to your ServiceNow instance as an administrator   1    Click System Properties   Email Properties     1  In the   Outbound Email Configuration   panel  select   Yes   next to the check box with the email that ServiceNow should send notifications to   To ensure you have relevant notifications configured in your instance    1  Navigate to   System Notification   Email   Notifications    1  Search for  Request Opened  and  Request Item Commented  and ensure they are activated   Reaching out to ServiceNow customer support if you run into any issues with the global configurations out to ServiceNow customer support if you run into any issues with the global configurations      Common problems  This section details frequently encountered issues and how they can be resolved        Failure to create a workspace  If you order the  create a workspace  catalog item and  nothing happens in ServiceNow and HCP Terraform does not create a workspace then there are several possible reasons why    Ensure your HCP Terraform token  hostname  and organization name is correct   1  Make sure to use a   Team API Token    This can be found in HCP Terraform under  API Tokens    1  Ensure the team API token has the correct permissions   1  Double check your organization name by copying and pasting it from HCP Terraform or Terraform Enterprise  1  Double check your host name   1  Make sure you created your team API token  in the same organization you are using  1  Test your configuration  First click   Update   to process any changes then   Test Config to make sure the connection is working     Verify your VCS configuration   1  The   Identifier   field should not have any spaces   The ServiceNow Service Catalog Integration requires that you format repository names in the  username repo name  format  1  The   Name   can be anything  but it is better to avoid special characters as per naming convention  1  Double check the OAuth token ID in your HCP Terraform Terraform Enterprise settings  To retrieve your OAuth token ID  navigate to your HCP Terraform organization s settings page  then click   Provider   in the left navigation bar under   Version Control          Failure to successfully order any catalog item  After placing an order for any catalog item  navigate to the comments section in the newly created RITM ticket   The latest comment will contain a response from HCP Terraform       Frequency of comments and outputs  When you place an order in the  Terraform Catalog  ServiceNow submits and processes the order  then attaches  additional comments  to the order to indicate whether HCP Terraform successfully created the workspace   By default  ServiceNow polls HCP Terraform every 5 minutes for the latest status of the Terraform run  ServiceNow does not show any comments until the next ping   To configure ServiceNow to poll HCP Terraform more frequently   1  Navigate to   All   Flow designer    1  Set the   Application   filter to   Terraform    1  Under the   Name   column click    Worker Poll Run State    1  Click on the trigger and adjust the interval to your desired schedule   1  Click   Done   Save   Activate   to save your changes       Using no code modules feature  If ServiceNow fails to deploy a no code module catalog item  verify the following   1  Ensure that your HCP Terraform organization has an  HCP Plus tier  https   www hashicorp com products terraform pricing  subscription   1  Ensure the name you enter for your no code module in the catalog user form matches the no code module in HCP Terraform       Updating no code workspaces  If the  update no code workspace  catalog item returns the output message  No update has been made to the workspace   then you have not upgraded your no code module in HCP Terraform        Application Scope  If you are making customizations and you encounter unexpected issues  make sure to change the scope from   Global   to   Terraform   and recreate your customized items in the   Terraform scope     For additional instructions on customizations  refer to the  example customizations   terraform cloud docs integrations service now service catalog terraform example customizations  documentation       MID server    If you are using a MID server in your configuration  check the connectivity by using the   Test Config   button on the configurations page   Additionally  when ServiceNow provisions a MID server  navigate to   MID Servers   Servers   to check if the status is  up  and  validated        Configuration  While the app allows multiple config entries  only one should be present as this can interfere with the functionality of the app


terraform When using ServiceNow with the HCP Terraform integration you will configure Service Catalog Configuration page title Service Catalog ServiceNow Service Catalog Integration HCP Terraform provision infrastructure using ServiceNow and HCP Terraform Configure Service Catalogs and VCS repositories to allow end users to

Answer:
---
page_title: Service Catalog - ServiceNow Service Catalog Integration - HCP Terraform
description: |-
  Configure Service Catalogs and VCS repositories to allow end users to
  provision infrastructure using ServiceNow and HCP Terraform.
---

# Service Catalog Configuration

When using ServiceNow with the HCP Terraform integration, you will configure
at least one service catalog item. You will also configure one or more version
control system (VCS) repositories or no-code modules containing the Terraform
configurations which will be used to provision that infrastructure. End users
will request infrastructure from the service catalog, and HCP Terraform will
fulfill the request by creating a new workspace, applying the configuration, and
then reporting the results back to ServiceNow.

## Prerequisites

Before configuring a service catalog, you must install and configure the
HCP Terraform integration software on your ServiceNow instance. These steps
are covered in the [installation documentation](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform).

Additionally, you must have have the following information:

1. The no-code module name or the OAuth token ID and repository identifier for
   each VCS repository that HCP Terraform will use to provision
   infrastructure. Your Terraform Admin will provide these to you. Learn more in
   [Configure VCS Repositories or No-Code
   Modules](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform/service-catalog-config#configure-vcs-repositories-or-no-code-modules).
1. Any Terraform or environment variables required by the configurations in the
   given VCS repositories or no-code modules.

Once these steps are complete, in order for end users to provision
infrastructure with ServiceNow and HCP Terraform, the ServiceNow Admin will
perform the following steps to make Service Items available to your end users.

1. Add at least one service catalog for use with Terraform.
1. If you are using the VCS flow, configure at least one one VCS repository in ServiceNow.
1. Create variable sets to define Terraform and environment variables to be used
   by HCP Terraform to provision infrastructure.

## Add the Terraform Service Catalog

-> **ServiceNow Role:** `admin`

First, add a Service Catalog for use with the Terraform integration. Depending
on your organization's needs, you might use a single service catalog, or
several. If you already have a Service Catalog to use with Terraform, skip to
the next step.

1. In ServiceNow, open the Service Catalog > Catalogs view by searching for
   "Service Catalog" in the left-hand navigation.
   1. Click the plus sign in the top right.
   1. Select "Catalogs > Terraform Catalog > Title and Image" and choose a
      location to add the Service Catalog.
   1. Close the "Sections" dialog box by clicking the "x" in the upper right-hand
      corner.

-> **Note:** In step 1, be sure to choose "Catalogs", not "Catalog" from the
left-hand navigation.

## Configure VCS Repositories or No-Code Modules

-> **ServiceNow Roles:** `admin` or `x_terraform.vcs_repositories_user`

Terraform workspaces created through the ServiceNow Service Catalog for
Terraform can be associated with a VCS
provider repository or be backed by a [no-code
module](/terraform/cloud-docs/no-code-provisioning/provisioning) in your
organization's private registry. Administrators determine which workspace type
end users can request from the Terraform Catalog. Below are the key
differences between the version control and no-code approaches.

### VCS configuration

To make infrastructure available to your users through version control
workspaces, you must add one or more VCS repositories containing Terraform
configurations to the Service Catalog for Terraform.

1. In ServiceNow, open the "Terraform > VCS Repositories" table by searching for
   "Terraform" in the left-hand navigation.
1. Click "New" to add a VCS repository, and fill in the following fields:
   - Name: The name for this repository. This name will be visible to end
     users, and does not have to be the same as the repository name as defined
     by your VCS provider. Ideally it will succinctly describe the
     infrastructure that will be provisioned by Terraform from the repository.
   - OAuth Token ID: The OAuth token ID that from your HCP Terraform
     organization's VCS providers settings. This ID specifies which VCS
     provider configured in HCP Terraform hosts the desired repository.
   - Identifier: The VCS repository that contains the Terraform configuration
     for this workspace template. Repository identifiers are determined by your
     VCS provider; they typically use a format like
     `<ORGANIZATION>/<REPO_NAME>` or `<PROJECT KEY>/<REPO_NAME>`. Azure DevOps
     repositories use the format `<ORGANIZATION>/<PROJECT>/_git/<REPO_NAME>`.
   - The remaining fields are optional.
     - Branch: The branch within the repository, if different from the default
       branch.
     - Working Directory: The directory within the repository containing
       Terraform configuration.
     - Terraform Version: The version of Terraform to use. This will default to
       the latest version of Terraform supported by your HCP Terraform
       instance.
1. Click "Submit".

![Screenshot: ServiceNow New VCS Repository](/img/docs/service-now-vcs-repository.png "Screenshot of the ServiceNow Terraform New VCS Repository page")

After configuring your repositories in ServiceNow, the names of those
repositories will be available in the "VCS Repository" dropdown menu a user
orders new workspaces through the following items in the Terraform Catalog:

- **Create Workspace**
- **Create Workspace with Variables**
- **Provision Resources**
- **Provision Resources with Variables**

### No-Code Module Configuration

In version 2.5.0 and newer, ServiceNow administrators can configure
Catalog Items using [no-code
modules](/terraform/cloud-docs/no-code-provisioning/provisioning). This release
introduces two new additions to the Terraform Catalog - no-code workspace
create and update Items. Both utilize no-code modules from the private registry
in HCP Terraform to enable end users to request infrastructure without writing
code.

<!-- BEGIN: TFC:only name:pnp-callout -->
@include 'tfc-package-callouts/nocode.mdx'
<!-- END: TFC:only name:pnp-callout -->

The following Catalog Items allow you to build and manage workspaces with
no-code modules:
- **Provision No-Code Workspace and Deploy Resources**: creates a new Terraform
  workspace based on a no-code module of your choice, supplies required variable
  values, runs and applies Terraform.
- **Update No-Code Workspace and Deploy Resources**: Updates an existing no-code
  workspace to the most recent no-code module version, updates that workspace's
  attached variable values, and then starts and applies a new Terraform run.

Administrators can skip configuring VCS repositories in ServiceNow when using
no-code modules. The only input required in the no-code workspace request form
is the name of the no-code module.

Before utilizing a no-code module, you must publish it to the your organization's
private module registry. With this one-time configuration complete, ServiceNow
Administrators can then call the modules through Catalog requests without
repository management, simplifying the use of infrastructure-as-code.

> **Hands On:** Try the [Self-service enablement with HCP Terraform and ServiceNow tutorial](/terraform/tutorials/it-saas/servicenow-no-code).

## Configure a Variable Set

Most Terraform configurations can be customized with Terraform variables or
environment variables. You can create a Variable Set within ServiceNow to
contain the variables needed for a given configuration. Your Terraform Admin
should provide these to you.

1. In ServiceNow, open the "Service Catalog > Variable Sets" table by searching for
   "variable sets" in the left-hand navigation.
1. Click "New" to add a Variable Set.
1. Select "Single-Row Variable Set".
   - Title: User-visible title for the variable set.
   - Internal name: The internal name for the variable set.
   - Order: The order in which the variable set will be displayed.
   - Type: Should be set to "Single Row"
   - Application: Should be set to "Terraform"
   - Display title: Whether the title is displayed to the end user.
   - Layout: How the variables in the set will be displayed on the screen.
   - Description: A long description of the variable set.
1. Click "Submit" to create the variable set.
1. Find and click on the title of the new variable set in the Variable Sets
   table.
1. At the bottom of the variable set details page, click "New" to add a new
   variable.

- Type: Should be "Single Line Text" for most variables, or "Masked" for
  variables containing sensitive values.
- Question: The user-visible question or label for the variable.
- Name: The internal name of the variable. This must be derived from the name of the
  Terraform or environment variable. Consult the table below to determine the
  proper prefix for each variable name.
- Tooltip: A tooltip to display for the variable.
- Example Text: Example text to show in the variable's input box.

1. Under the "Default Value" tab, you can set a default value for the variable.
1. Continue to add new variables corresponding to the Terraform and environment
   variables the configuration requires.

When the Terraform integration applies configuration, it will map ServiceNow
variables to Terraform and environment variables using the following convention.
ServiceNow variables that begin with "sensitive_" will be saved as sensitive
variables within HCP Terraform.

| ServiceNow Variable Name         | HCP Terraform Variable                                   |
| -------------------------------- | ---------------------------------------------------------- |
| `tf_var_VARIABLE_NAME`           | Terraform Variable: `VARIABLE_NAME`                        |
| `tf_env_ENV_NAME`                | Environment Variable: `ENV_NAME`                           |
| `sensitive_tf_var_VARIABLE_NAME` | Sensitive Terraform Variable (Write Only): `VARIABLE_NAME` |
| `sensitive_tf_env_ENV_NAME`      | Sensitive Environment Variable (Write Only): `ENV_NAME`    |

## Provision Infrastructure

Once you configure the Service Catalog for Terraform, ServiceNow users
can request infrastructure to be provisioned by HCP Terraform.

These requests will be fulfilled by HCP Terraform, which will:

1. Create a new workspace from the no-code module or the VCS repository provided by ServiceNow.
1. Configure variables for that workspace, also provided by ServiceNow.
1. Plan and apply the change.
1. Report the results, including any outputs from Terraform, to ServiceNow.

Once this is complete, ServiceNow will reflect that the Request Item has been
provisioned.

-> **Note:** The integration creates workspaces with
[auto-apply](/terraform/cloud-docs/workspaces/settings#auto-apply-and-manual-apply)
enabled. HCP Terraform will queue an apply for these workspaces whenever
changes are merged to the associated VCS repositories. This is known as the
[VCS-driven run workflow](/terraform/cloud-docs/run/ui). It is important to keep in mind
that all of the ServiceNow workspaces connected to a given repository will be
updated whenever changes are merged to the associated branch in that repository.

## Execution Mode

If using v2.2.0 or above, the Service Catalog app allows you to set an [execution mode](/terraform/cloud-docs/workspaces/settings#execution-mode) for your Terraform workspaces. There are two modes to choose from:

 - The default value is "Remote", which instructs HCP Terraform to perform runs on its disposable virtual machines.
 - Selecting "Agent" mode allows you to run Terraform operations on isolated, private, or on-premises infrastructure. This option requires you to create an Agent Pool in your organization beforehand, then provide that Agent Pool's id when you order a new workspace through the Service Catalog.

<!-- BEGIN: TFC:only name:pnp-callout -->
@include 'tfc-package-callouts/agents.mdx'
<!-- END: TFC:only name:pnp-callout -->

## Workspace Name

Version 2.4.0 of the Service Catalog for Terraform introduces the ability to set custom names for your Terraform workspaces. You can choose a prefix for your workspace name that the Service Catalog app will append the ServiceNow RITM number to. If you do not define a workspace prefix, ServiceNow will use RITM number as the workspace name.

Workspace names can include letters, numbers, dashes (`-`), and underscores (`_`), and should not exceed 90 characters.
Refer to the [workspace naming recommendations](/terraform/cloud-docs/workspaces/create#workspace-naming) for best practices.

## Workspace Tags

Version 2.4.0 also allows you to add custom tags to your Terraform workspaces. Use the "Workspace Tags" field to provide a comma-separated list of tags that will be parsed and attached to the workspace in HCP Terraform.

Tags give you an easier way to categorize, filter, and manage workspaces provisioned through the Service Catalog for Terraform.
We recommend that you set naming conventions for tags with your end users to avoid variations such as `ec2`, `aws-ec2`, `aws_ec2`.

Workspace tags have a 255 character limit and can contain letters, numbers, colons, hyphens, and underscores. Refer to the [workspace tagging rules](/terraform/cloud-docs/workspaces/create#workspace-tags) for more details.

page title  Service Catalog   ServiceNow Service Catalog Integration   HCP Terraform description       Configure Service Catalogs and VCS repositories to allow end users to   provision infrastructure using ServiceNow and HCP Terraform         Service Catalog Configuration  When using ServiceNow with the HCP Terraform integration  you will configure at least one service catalog item  You will also configure one or more version control system  VCS  repositories or no code modules containing the Terraform configurations which will be used to provision that infrastructure  End users will request infrastructure from the service catalog  and HCP Terraform will fulfill the request by creating a new workspace  applying the configuration  and then reporting the results back to ServiceNow      Prerequisites  Before configuring a service catalog  you must install and configure the HCP Terraform integration software on your ServiceNow instance  These steps are covered in the  installation documentation   terraform cloud docs integrations service now service catalog terraform    Additionally  you must have have the following information   1  The no code module name or the OAuth token ID and repository identifier for    each VCS repository that HCP Terraform will use to provision    infrastructure  Your Terraform Admin will provide these to you  Learn more in     Configure VCS Repositories or No Code    Modules   terraform cloud docs integrations service now service catalog terraform service catalog config configure vcs repositories or no code modules   1  Any Terraform or environment variables required by the configurations in the    given VCS repositories or no code modules   Once these steps are complete  in order for end users to provision infrastructure with ServiceNow and HCP Terraform  the ServiceNow Admin will perform the following steps to make Service Items available to your end users   1  Add at least one service catalog for use with Terraform  1  If you are using the VCS flow  configure at least one one VCS repository in ServiceNow  1  Create variable sets to define Terraform and environment variables to be used    by HCP Terraform to provision infrastructure      Add the Terraform Service Catalog       ServiceNow Role     admin   First  add a Service Catalog for use with the Terraform integration  Depending on your organization s needs  you might use a single service catalog  or several  If you already have a Service Catalog to use with Terraform  skip to the next step   1  In ServiceNow  open the Service Catalog   Catalogs view by searching for     Service Catalog  in the left hand navigation     1  Click the plus sign in the top right     1  Select  Catalogs   Terraform Catalog   Title and Image  and choose a       location to add the Service Catalog     1  Close the  Sections  dialog box by clicking the  x  in the upper right hand       corner        Note    In step 1  be sure to choose  Catalogs   not  Catalog  from the left hand navigation      Configure VCS Repositories or No Code Modules       ServiceNow Roles     admin  or  x terraform vcs repositories user   Terraform workspaces created through the ServiceNow Service Catalog for Terraform can be associated with a VCS provider repository or be backed by a  no code module   terraform cloud docs no code provisioning provisioning  in your organization s private registry  Administrators determine which workspace type end users can request from the Terraform Catalog  Below are the key differences between the version control and no code approaches       VCS configuration  To make infrastructure available to your users through version control workspaces  you must add one or more VCS repositories containing Terraform configurations to the Service Catalog for Terraform   1  In ServiceNow  open the  Terraform   VCS Repositories  table by searching for     Terraform  in the left hand navigation  1  Click  New  to add a VCS repository  and fill in the following fields       Name  The name for this repository  This name will be visible to end      users  and does not have to be the same as the repository name as defined      by your VCS provider  Ideally it will succinctly describe the      infrastructure that will be provisioned by Terraform from the repository       OAuth Token ID  The OAuth token ID that from your HCP Terraform      organization s VCS providers settings  This ID specifies which VCS      provider configured in HCP Terraform hosts the desired repository       Identifier  The VCS repository that contains the Terraform configuration      for this workspace template  Repository identifiers are determined by your      VCS provider  they typically use a format like        ORGANIZATION   REPO NAME   or   PROJECT KEY   REPO NAME    Azure DevOps      repositories use the format   ORGANIZATION   PROJECT   git  REPO NAME         The remaining fields are optional         Branch  The branch within the repository  if different from the default        branch         Working Directory  The directory within the repository containing        Terraform configuration         Terraform Version  The version of Terraform to use  This will default to        the latest version of Terraform supported by your HCP Terraform        instance  1  Click  Submit      Screenshot  ServiceNow New VCS Repository   img docs service now vcs repository png  Screenshot of the ServiceNow Terraform New VCS Repository page    After configuring your repositories in ServiceNow  the names of those repositories will be available in the  VCS Repository  dropdown menu a user orders new workspaces through the following items in the Terraform Catalog       Create Workspace       Create Workspace with Variables       Provision Resources       Provision Resources with Variables        No Code Module Configuration  In version 2 5 0 and newer  ServiceNow administrators can configure Catalog Items using  no code modules   terraform cloud docs no code provisioning provisioning   This release introduces two new additions to the Terraform Catalog   no code workspace create and update Items  Both utilize no code modules from the private registry in HCP Terraform to enable end users to request infrastructure without writing code        BEGIN  TFC only name pnp callout      include  tfc package callouts nocode mdx       END  TFC only name pnp callout      The following Catalog Items allow you to build and manage workspaces with no code modules      Provision No Code Workspace and Deploy Resources    creates a new Terraform   workspace based on a no code module of your choice  supplies required variable   values  runs and applies Terraform      Update No Code Workspace and Deploy Resources    Updates an existing no code   workspace to the most recent no code module version  updates that workspace s   attached variable values  and then starts and applies a new Terraform run      Administrators can skip configuring VCS repositories in ServiceNow when using no code modules  The only input required in the no code workspace request form is the name of the no code module    Before utilizing a no code module  you must publish it to the your organization s private module registry  With this one time configuration complete  ServiceNow Administrators can then call the modules through Catalog requests without repository management  simplifying the use of infrastructure as code       Hands On    Try the  Self service enablement with HCP Terraform and ServiceNow tutorial   terraform tutorials it saas servicenow no code       Configure a Variable Set  Most Terraform configurations can be customized with Terraform variables or environment variables  You can create a Variable Set within ServiceNow to contain the variables needed for a given configuration  Your Terraform Admin should provide these to you   1  In ServiceNow  open the  Service Catalog   Variable Sets  table by searching for     variable sets  in the left hand navigation  1  Click  New  to add a Variable Set  1  Select  Single Row Variable Set        Title  User visible title for the variable set       Internal name  The internal name for the variable set       Order  The order in which the variable set will be displayed       Type  Should be set to  Single Row       Application  Should be set to  Terraform       Display title  Whether the title is displayed to the end user       Layout  How the variables in the set will be displayed on the screen       Description  A long description of the variable set  1  Click  Submit  to create the variable set  1  Find and click on the title of the new variable set in the Variable Sets    table  1  At the bottom of the variable set details page  click  New  to add a new    variable     Type  Should be  Single Line Text  for most variables  or  Masked  for   variables containing sensitive values    Question  The user visible question or label for the variable    Name  The internal name of the variable  This must be derived from the name of the   Terraform or environment variable  Consult the table below to determine the   proper prefix for each variable name    Tooltip  A tooltip to display for the variable    Example Text  Example text to show in the variable s input box   1  Under the  Default Value  tab  you can set a default value for the variable  1  Continue to add new variables corresponding to the Terraform and environment    variables the configuration requires   When the Terraform integration applies configuration  it will map ServiceNow variables to Terraform and environment variables using the following convention  ServiceNow variables that begin with  sensitive   will be saved as sensitive variables within HCP Terraform     ServiceNow Variable Name           HCP Terraform Variable                                                                                tf var VARIABLE NAME              Terraform Variable   VARIABLE NAME                              tf env ENV NAME                   Environment Variable   ENV NAME                                 sensitive tf var VARIABLE NAME    Sensitive Terraform Variable  Write Only    VARIABLE NAME       sensitive tf env ENV NAME         Sensitive Environment Variable  Write Only    ENV NAME           Provision Infrastructure  Once you configure the Service Catalog for Terraform  ServiceNow users can request infrastructure to be provisioned by HCP Terraform   These requests will be fulfilled by HCP Terraform  which will   1  Create a new workspace from the no code module or the VCS repository provided by ServiceNow  1  Configure variables for that workspace  also provided by ServiceNow  1  Plan and apply the change  1  Report the results  including any outputs from Terraform  to ServiceNow   Once this is complete  ServiceNow will reflect that the Request Item has been provisioned        Note    The integration creates workspaces with  auto apply   terraform cloud docs workspaces settings auto apply and manual apply  enabled  HCP Terraform will queue an apply for these workspaces whenever changes are merged to the associated VCS repositories  This is known as the  VCS driven run workflow   terraform cloud docs run ui   It is important to keep in mind that all of the ServiceNow workspaces connected to a given repository will be updated whenever changes are merged to the associated branch in that repository      Execution Mode  If using v2 2 0 or above  the Service Catalog app allows you to set an  execution mode   terraform cloud docs workspaces settings execution mode  for your Terraform workspaces  There are two modes to choose from      The default value is  Remote   which instructs HCP Terraform to perform runs on its disposable virtual machines     Selecting  Agent  mode allows you to run Terraform operations on isolated  private  or on premises infrastructure  This option requires you to create an Agent Pool in your organization beforehand  then provide that Agent Pool s id when you order a new workspace through the Service Catalog        BEGIN  TFC only name pnp callout      include  tfc package callouts agents mdx       END  TFC only name pnp callout         Workspace Name  Version 2 4 0 of the Service Catalog for Terraform introduces the ability to set custom names for your Terraform workspaces  You can choose a prefix for your workspace name that the Service Catalog app will append the ServiceNow RITM number to  If you do not define a workspace prefix  ServiceNow will use RITM number as the workspace name   Workspace names can include letters  numbers  dashes        and underscores        and should not exceed 90 characters  Refer to the  workspace naming recommendations   terraform cloud docs workspaces create workspace naming  for best practices      Workspace Tags  Version 2 4 0 also allows you to add custom tags to your Terraform workspaces  Use the  Workspace Tags  field to provide a comma separated list of tags that will be parsed and attached to the workspace in HCP Terraform    Tags give you an easier way to categorize  filter  and manage workspaces provisioned through the Service Catalog for Terraform  We recommend that you set naming conventions for tags with your end users to avoid variations such as  ec2    aws ec2    aws ec2    Workspace tags have a 255 character limit and can contain letters  numbers  colons  hyphens  and underscores  Refer to the  workspace tagging rules   terraform cloud docs workspaces create workspace tags  for more details


terraform The Terraform ServiceNow integration can be customized by ServiceNow developers Terraform ServiceNow Service Catalog Integration Developer Reference page title Developer Reference ServiceNow Service Catalog Integration HCP Terraform using the information found in this document Developer reference for the ServiceNow Service Catalog Integration

Answer:
---
page_title: Developer Reference - ServiceNow Service Catalog Integration - HCP Terraform
description: Developer reference for the ServiceNow Service Catalog Integration.
---

# Terraform ServiceNow Service Catalog Integration Developer Reference

The Terraform ServiceNow integration can be customized by ServiceNow developers
using the information found in this document.

## Terraform Variables and ServiceNow Variable Sets

ServiceNow has the concept of a Variable Set which is a collection of ServiceNow
Variables that can be referenced in a Flow from a Service Catalog item. The
Terraform Integration codebase can create [Terraform Variables and Terraform
Environment Variables](/terraform/cloud-docs/workspaces/variables) via the API using the
`tf_variable.createVariablesFromSet()` function.

This function looks for variables following these conventions:

| ServiceNow Variable Name         | HCP Terraform Variable                                   |
| -------------------------------- | ---------------------------------------------------------- |
| `tf_var_VARIABLE_NAME`           | Terraform Variable: `VARIABLE_NAME`                        |
| `tf_env_ENV_NAME`                | Environment Variable: `ENV_NAME`                           |
| `sensitive_tf_var_VARIABLE_NAME` | Sensitive Terraform Variable (Write Only): `VARIABLE_NAME` |
| `sensitive_tf_env_ENV_NAME`      | Sensitive Environment Variable (Write Only): `ENV_NAME`    |

This function takes the ServiceNow Variable Set and HCP Terraform workspace
ID. It will loop through the given variable set collection and create any
necessary Terraform variables or environment variables in the workspace.

## Customizing with ServiceNow "Script Includes" Libraries

The Terraform/ServiceNow Integration codebase includes [ServiceNow Script
Includes
Classes](https://docs.servicenow.com/csh?topicname=c_ScriptIncludes.html&version=latest)
that are used to interface with HCP Terraform. The codebase also includes
example catalog items and flows that implement the interface to the HCP Terraform API.

These classes and examples can be used to help create ServiceNow Catalog Items
customized to your specific ServiceNow instance and requirements.

### Script Include Classes

The ServiceNow Script Include Classes can be found in the ServiceNow Studio >
Server Development > Script Include.

| Class Name            | Description                                                |
| --------------------- | ---------------------------------------------------------- |
| `tf_config`           | Helper to pull values from the SN Terraform Configs Table  |
| `tf_get_workspace`    | Client-callable script to retrieve workspace data          |
| `tf_http`             | ServiceNow HTTP REST wrapper for requests to the Terraform API |
| `tf_no_code_workspace`| Resources for Terraform no-code module API requests       |
| `tf_run`              | Resources for Terraform run API requests                   |
| `tf_terraform_record` | Manage ServiceNow Terraform Table Records                  |
| `tf_test_config`      | Client-callable script to test Terraform connectivity      |
| `tf_util`             | Miscellaneous helper functions                             |
| `tf_variable`         | Resources for Terraform variable API Requests              |
| `tf_vcs_record`       | Manage ServiceNow Terraform VCS repositories table records |
| `tf_workspace`        | Resources for Terraform workspace API requests             |

### Example Service Catalog Flows and Actions

The ServiceNow Service Catalog for Terraform provides sample catalog items that use **Flows**
and **Workflows** as their primary process engines.  **Flows** are a newer solution developed
by ServiceNow and are generally preferred over **Workflows**. To see which engine an item is using, open it
in the edit mode and navigate to the **Process Engine** tab. For example, **Create Workspace** uses a **Workflow**,
whereas **Create Workspace Flow** is built upon a **Flow**. You can access both in the **Studio**. You can also
manage **Flows** in the **Flow Designer**. To manage **Workflows**, navigate to **All > Workflow Editor**.

You can find the ServiceNow Example Flows for Terraform in the **ServiceNow Studio > Flows** (or **All > Flow Designer**).
Search for items that belong to the **Terraform** application. By default, Flows execute when someone submits an order request
for a catalog item based on a Flow. Admins can customize the Flows and Actions to add approval flows, set approval rules based
on certain conditions, and configure multiple users or roles as approvers for specific catalog items.

| Flow Name                     | Description                                                                                |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Create Workspace              | Creates a new HCP Terraform workspace from VCS repository.                                                                                |
| Create Workspace with Vars    | Creates a new HCP Terraform workspace from VCS repository and creates any variables provided.                                                                              |
| Create Run                    | Creates and queues a new run in the HCP Terraform workspace.                                                                                |
| Apply Run                     | Applies a run in the HCP Terraform workspace.                                                                                |
| Provision Resources           | Creates a new HCP Terraform workspace (with auto-apply), creates and queues a run, then applies the run when ready.                                                                     |
| Provision Resources with Vars | Creates a new HCP Terraform workspace (with auto-apply), creates any variables, creates/queues a run, applies the run when ready.
| Provision No-Code Workspace and Deploy Resources | Creates a new HCP Terraform workspace based on a no-code module configured in the private registry (with auto-apply), creates any variables, creates and queues a run, then applies the run when ready.                                                |
| Delete Workspace              | Creates a destroy run plan.                                                                                |
| Worker Poll Run State         | Polls the HCP Terraform API for the current run state of a workspace.                                                                                |
| Worker Poll Apply Run         | Polls the HCP Terraform API and applies any pending Terraform runs.                                                                                |
| Worker Poll Destroy Workspace | Queries ServiceNow Terraform Records for resources marked `is_destroyable`, applies the destroy run to destroy resources, and deletes the corresponding Terraform workspace. |
| Update No-Code Workspace and Deploy Resources | Updates an existing no-code workspace to the most recent no-code module version, updates that workspace's attached variable values, and then starts a new Terraform run.
| Update Workspace              | Updates HCP Terraform workspace configurations, such as VCS repository, description, project, execution mode, and agent pool ID (if applicable).                               |
| Update Workspace with Vars    | Allows you to change details about the HCP Terraform workspace configurations and attached variable values.                                                          |
| Update Resources              | Updates HCP Terraform workspace details and starts a new Terraform run with these new values.                                                                              |
| Update Resources with Vars    | Updates your existing HCP Terraform workspace and its variables, then starts a Terraform run with these updated values.                                                    |

## ServiceNow ACLs

Access control lists (ACLs) restrict user access to objects and operations based
on permissions granted. This integration includes the following roles that can
be used to manage various components.

| Access Control Roles                | Description                                                                                |
| :---------------------------------- | ----------------------------------------------------------------------------------------------- |
| `x_terraform.config_user`           | Can manage the connection from the ServiceNow application to your HCP Terraform organization. |
| `x_terraform.terraform_user`        | Can manage all of the Terraform resources created in ServiceNow.                                |
| `x_terraform.vcs_repositories_user` | Can manage the VCS repositories available for catalog items to be ordered by end-users.         |

For users who only need to order from the Terraform Catalog, we recommend
creating another role with read-only permissions for
`x_terraform_vcs_repositories` to view the available repositories for ordering
infrastructure. Install the Terraform ServiceNow Service Catalog integration by
following [the installation guide](/terraform/cloud-docs/integrations/service-now/service-catalog-terraform).

page title  Developer Reference   ServiceNow Service Catalog Integration   HCP Terraform description  Developer reference for the ServiceNow Service Catalog Integration         Terraform ServiceNow Service Catalog Integration Developer Reference  The Terraform ServiceNow integration can be customized by ServiceNow developers using the information found in this document      Terraform Variables and ServiceNow Variable Sets  ServiceNow has the concept of a Variable Set which is a collection of ServiceNow Variables that can be referenced in a Flow from a Service Catalog item  The Terraform Integration codebase can create  Terraform Variables and Terraform Environment Variables   terraform cloud docs workspaces variables  via the API using the  tf variable createVariablesFromSet    function   This function looks for variables following these conventions     ServiceNow Variable Name           HCP Terraform Variable                                                                                tf var VARIABLE NAME              Terraform Variable   VARIABLE NAME                              tf env ENV NAME                   Environment Variable   ENV NAME                                 sensitive tf var VARIABLE NAME    Sensitive Terraform Variable  Write Only    VARIABLE NAME       sensitive tf env ENV NAME         Sensitive Environment Variable  Write Only    ENV NAME        This function takes the ServiceNow Variable Set and HCP Terraform workspace ID  It will loop through the given variable set collection and create any necessary Terraform variables or environment variables in the workspace      Customizing with ServiceNow  Script Includes  Libraries  The Terraform ServiceNow Integration codebase includes  ServiceNow Script Includes Classes  https   docs servicenow com csh topicname c ScriptIncludes html version latest  that are used to interface with HCP Terraform  The codebase also includes example catalog items and flows that implement the interface to the HCP Terraform API   These classes and examples can be used to help create ServiceNow Catalog Items customized to your specific ServiceNow instance and requirements       Script Include Classes  The ServiceNow Script Include Classes can be found in the ServiceNow Studio   Server Development   Script Include     Class Name              Description                                                                                tf config              Helper to pull values from the SN Terraform Configs Table       tf get workspace       Client callable script to retrieve workspace data               tf http                ServiceNow HTTP REST wrapper for requests to the Terraform API      tf no code workspace   Resources for Terraform no code module API requests            tf run                 Resources for Terraform run API requests                        tf terraform record    Manage ServiceNow Terraform Table Records                       tf test config         Client callable script to test Terraform connectivity           tf util                Miscellaneous helper functions                                  tf variable            Resources for Terraform variable API Requests                   tf vcs record          Manage ServiceNow Terraform VCS repositories table records      tf workspace           Resources for Terraform workspace API requests                    Example Service Catalog Flows and Actions  The ServiceNow Service Catalog for Terraform provides sample catalog items that use   Flows    and   Workflows   as their primary process engines     Flows   are a newer solution developed  by ServiceNow and are generally preferred over   Workflows    To see which engine an item is using  open it  in the edit mode and navigate to the   Process Engine   tab  For example    Create Workspace   uses a   Workflow     whereas   Create Workspace Flow   is built upon a   Flow    You can access both in the   Studio    You can also  manage   Flows   in the   Flow Designer    To manage   Workflows    navigate to   All   Workflow Editor     You can find the ServiceNow Example Flows for Terraform in the   ServiceNow Studio   Flows    or   All   Flow Designer      Search for items that belong to the   Terraform   application  By default  Flows execute when someone submits an order request  for a catalog item based on a Flow  Admins can customize the Flows and Actions to add approval flows  set approval rules based  on certain conditions  and configure multiple users or roles as approvers for specific catalog items      Flow Name                       Description                                                                                Create Workspace                Creates a new HCP Terraform workspace from VCS repository                                                                                Create Workspace with Vars      Creates a new HCP Terraform workspace from VCS repository and creates any variables provided                                                                                Create Run                      Creates and queues a new run in the HCP Terraform workspace                                                                                Apply Run                       Applies a run in the HCP Terraform workspace                                                                                Provision Resources             Creates a new HCP Terraform workspace  with auto apply   creates and queues a run  then applies the run when ready                                                                          Provision Resources with Vars   Creates a new HCP Terraform workspace  with auto apply   creates any variables  creates queues a run  applies the run when ready      Provision No Code Workspace and Deploy Resources   Creates a new HCP Terraform workspace based on a no code module configured in the private registry  with auto apply   creates any variables  creates and queues a run  then applies the run when ready                                                     Delete Workspace                Creates a destroy run plan                                                                                Worker Poll Run State           Polls the HCP Terraform API for the current run state of a workspace                                                                                Worker Poll Apply Run           Polls the HCP Terraform API and applies any pending Terraform runs                                                                                Worker Poll Destroy Workspace   Queries ServiceNow Terraform Records for resources marked  is destroyable   applies the destroy run to destroy resources  and deletes the corresponding Terraform workspace      Update No Code Workspace and Deploy Resources   Updates an existing no code workspace to the most recent no code module version  updates that workspace s attached variable values  and then starts a new Terraform run         Update Workspace                Updates HCP Terraform workspace configurations  such as VCS repository  description  project  execution mode  and agent pool ID  if applicable                                     Update Workspace with Vars      Allows you to change details about the HCP Terraform workspace configurations and attached variable values                                                               Update Resources                Updates HCP Terraform workspace details and starts a new Terraform run with these new values                                                                                Update Resources with Vars      Updates your existing HCP Terraform workspace and its variables  then starts a Terraform run with these updated values                                                           ServiceNow ACLs  Access control lists  ACLs  restrict user access to objects and operations based on permissions granted  This integration includes the following roles that can be used to manage various components     Access Control Roles                  Description                                                                                x terraform config user              Can manage the connection from the ServiceNow application to your HCP Terraform organization       x terraform terraform user           Can manage all of the Terraform resources created in ServiceNow                                      x terraform vcs repositories user    Can manage the VCS repositories available for catalog items to be ordered by end users             For users who only need to order from the Terraform Catalog  we recommend creating another role with read only permissions for  x terraform vcs repositories  to view the available repositories for ordering infrastructure  Install the Terraform ServiceNow Service Catalog integration by following  the installation guide   terraform cloud docs integrations service now service catalog terraform