Problem
When integrating ServiceNow with Terraform Enterprise (TFE) using the Terraform ServiceNow Catalog Integration v2.4.0, a workspace may be created successfully, but TFE fails to retrieve code from the configured VCS provider. This can result in errors such as Unexpected Token: T or Can not read property from id undefined.
Prerequisites
- Terraform ServiceNow Service Catalog Integration v2.4.0
Cause
This problem typically arises from a mismatch between the Terraform binary version specified in the ServiceNow catalog item and the versions available for use in the Terraform Enterprise installation. When TFE cannot find or is not permitted to use the requested version, it returns an error that the ServiceNow integration cannot parse correctly.
Solutions
Solution 1: Identify the Error in ServiceNow Logs
First, locate the specific error message from TFE within the ServiceNow system logs to confirm the cause.
- In ServiceNow, navigate to All > Logs > System Logs.
-
Use the log filtering options to locate the error message associated with the failed catalog item. You can apply additional filters, such as date and time, to narrow the search.
-
Examine the HTTP Request Body in the logs. The TFE API response will contain a detailed error message indicating the version mismatch.
{ "errors": [ { "status": "422", "title": "invalid attribute", "detail": "Terraform version \"v1.7.4\" does not resolve to a version of Terraform present in this Terraform Enterprise installation, or this organization is not permitted to use it.", "source": { "pointer": "/data/attributes/terraform-version" } } ] }
Solution 2: Update the Terraform Version in ServiceNow
After confirming the error, update the Terraform version in the ServiceNow VCS Repositories configuration to match a version available in your TFE installation.
- In ServiceNow, navigate to Terraform > VCS Repositories.
- Select the repository configuration for your catalog item.
-
Ensure that the Terraform Version field specifies a version that is present and accessible within your TFE organization. Avoid leaving this field blank to prevent version conflicts.
After updating and saving the configuration, attempt to provision the catalog item again.
Additional Information
- For more details on the integration, refer to the Service Catalog for Terraform documentation.