Example Customizations
This example use case creates a Terraform Catalog Item for requesting resources with custom variable values passed to the Terraform configuration.
Change the scope
When you make a customization to the app, ensure you switch to the "Terraform" scope. This guarantees that all items you create are correctly assigned to that scope. To change the scope in your ServiceNow instance, click the globe icon at the top right of the screen. For detailed instructions on changing the scope, refer to the ServiceNow documentation.
Make a copy of the existing Catalog Item
The ServiceNow Service Catalog for Terraform application provides pre-configured Catalog Items for immediate use. We recommend creating a copy of the most recent version of the Catalog Item to ensure you have access to the latest features and improvements. Make a copy of the most appropriate Catalog Item for your specific business requirements by following these steps:
- Navigate to All > Service Catalog > Catalogs > Terraform Catalog, and review the Catalog Items based on flows, whose names use the suffix "Flow". We recommend choosing Flows over Workflows because Flows provide enhanced functionality and performance and are actively developed by ServiceNow. For more information, refer to Catalog Items based on Flows vs. Workflows.
- Open the Catalog Item in editing mode:
- Click the Catalog Item to open the request form.
- Click ... in the top right corner.
- Select Configure Item from the menu.
- Click the Process Engine tab in the Catalog Item configuration. Take note of the Flow name associated with the Catalog Item, because you need to create a copy of this Flow as well.
- Start the copying process:
- Click the Copy button above the Related Links section.
- Assign a new name to the copied Catalog Item.
- Optionally, modify the description and short description fields. Right-click the header and select Save.
Adjust the Variable Set
If a Catalog Item requires users to input variable values, you must update the variable set with those required variables. Although some default Catalog Items come with pre-defined example variables, it is common practice to remove these and replace them with your own custom variables.
- Create a new Variable Set.
- On the Catalog Item's configuration page, under the Related Links section, click the Variable Sets tab.
- Click the New button to create a new variable set. Ensure that the variables in your new set match the variables required by your Terraform configuration.
- Select Single-Row Variable Set and provide a title and description.
- Click Submit. Upon submission, you will be redirected back to the Catalog Item's configuration page.
- Click the name of your newly created Variable Set and create your variables. You must follow the naming convention for Terraform variables. ServiceNow offers various types of variable representation (such as strings, booleans, and dropdown menus). Refer to the ServiceNow documentation on variables and select the types that best suit your use case. You can also set default values for the variables in the Default Value tab, which ServiceNow prefills for the end users.
- Attach the newly created Variable Set to your custom Catalog Item and remove
the default Workspace Variables.
- Return to the Variable Sets tab on the Catalog Item's configuration page and click the Edit button.
- Move the "Workspace Variables" Set from the right side to the left side and click Save. Do not remove the "Workspace Request Create" or the "Workspace Request Update" Sets.
Make a copy of the Flow and Action
Open the ServiceNow Studio by navigating to All > Studio and open the "Terraform" application. Once in the Terraform application, navigate to Flow Designer > Flows.
Another way to access the ServiceNow Studio is to click All, select "Flow Designer", then select Flows. You can set the Application filter to "Terraform" to quickly find the desired Flow.
Open the Flow referenced in your Catalog Item. Click ... in the top right corner of the Flow Designer interface and select Copy flow. Provide a name for the copied Flow and click Copy.
Customize your newly copied Flow by clicking Edit flow.
- Do not change the Service Catalog trigger.
- Update the "Get Catalog Variables" action:
- Keep the "Requested Item Record" in the Submitted Request field.
- Select your newly created Catalog Item from the dropdown menu for Template Catalog Item.
- Move all of your variables to the Selected side in the Catalog Variables section. Remove any previous example variables from the Available side.
- Click Done to finish configuring this Action.
Unfold the second Action in the Flow and click the arrow to open it in the Action Designer.
- Click ... in the top right corner and select Copy Action. Rename it and click Copy.
- In the the Inputs section, remove any previous example variables.
- Add your custom variables by clicking the Create Input button. Ensure that the variable names match your Catalog Item variables and select the variable type that matches each variable. Click Save.
- Open the Script step within the Action. Remove any example variables and add your custom variables by clicking Create Variable at the bottom. Enter the name of each variable and drag the corresponding data pill from the right into the Value field.
- Click Save and then Publish.
Reopen the Flow and attach the newly created Action to the Flow after "Get Catalog Variables" step:
- Remove the "Create Terraform Workspace with Vars" Action that you copied earlier and replace it with your newly created Action.
- Connect the new Action to the Flow by dragging and dropping the data pills from the "Get Catalog Variables" Action to the corresponding inputs of your new Action. Click Done to save this step.
- Click Save.
- Click Activate to enable the Flow and make it available for use.
Set the Flow for your Catalog Item
- Navigate back to the Catalog by clicking on All and then go to Service Catalog > Catalogs > Terraform Catalog.
- Locate your custom Catalog Item and click ... at the top of the item. From the dropdown menu, select Configure item.
- In the configuration settings, click the Process Engine tab.
- In the Flow field, search for the Flow you recently created. Click the Flow then click the Update.
Test the Catalog Item
The new item is now available in the Terraform Service Catalog. To make the new item accessible to your end users via the Service Portal, follow these steps:
- Navigate to the configuration page of the item you want to make available.
- Locate the Catalogs field on the configuration page and click the lock icon next to it.
- In the search bar, type "Service Catalog" and select it from the search results. Add "Service Catalog" to the list of catalogs associated with the item. Click the lock icon again to lock the changes.
- Click the Update button at the top of the page.
After completing these steps, end users will be able to access the new item through the Service Portal of your ServiceNow instance. You can access the Service Portal by navigating to All > Service Portal Home.