Terraform Configuration/Discovery <!-- .SOKMKBArticle div.margin { padding: 10px 40px 40px 30px; color: #283d40; font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; font-size: 10pt; } .SOKMKBArticle div.fed{ background-color: #f5f8fa; border: 1px solid; border-color: #bfbfbf; padding: 10px; } .SOKMKBArticle .FedRestricted{ background-color: #c00000; color: #ffffff; padding: 10px; margin-top: 10px; text-align: center; font-size: 14pt; font-weight: bold; } .SOKMKBArticle .CustRestricted{ background-color: #ff0000; color: #ffffff; padding: 10px; margin-top: 10px; text-align: center; font-size: 14pt; font-weight: bold; } .SOKMKBArticle .SNRestricted{ background-color: #ea700d; color: #ffffff; padding: 10px; margin-top: 10px; text-align: center; font-size: 14pt; font-weight: bold; } .SOKMKBArticle .SNConfidential{ background-color: #ffc000; color: #ffffff; padding: 10px; margin-top: 10px; text-align: center; font-size: 14pt; font-weight: bold; } .SOKMKBArticle .Public{ background-color: #00b050; color: #ffffff; padding: 10px; margin-top: 10px; text-align: center; font-size: 14pt; font-weight: bold; } .SOKMKBArticle table.tocTable { border: 1px solid; border-color: #f2f2f2; background-color: #f2f2f2; padding-top: .6em; padding-bottom: .6em; padding-left: .9em; padding-right: .6em; } .SOKMKBArticle table.noteTable { align: left; border: none; border-color: #81b5a1; background-color: #f2f2f2; width: 100%; border-spacing: 2; font-size: 11px; } .SOKMKBArticle table.internalTable { border-top: 1px solid; border-left: 1px solid; border-color: #81b5a1; width: 100%; border-spacing: 1px; } .SOKMKBArticle .sp td { border-bottom: 1px solid; border-right: 1px solid; border-color: #81b5a1; background-color: #ffffff; height: 20px; padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; } .SOKMKBArticle .sphr td { border-right: 1px solid; border-bottom: 1px solid; border-color: #81b5a1; background-color: rgb(245, 245, 245); padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; height: 20px; } .SOKMKBArticle .sh td { border-bottom: 1px solid; border-right: 1px solid; border-color: #81b5a1; background-color: #81b5a1; color: #ffffff; height: 20px; padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; } .SOKMKBArticle th { padding-top: .5em; padding-bottom: .5em; padding-left: .5em; padding-right: .5em; border-bottom: 1px solid; border-right: 1px solid; border-color: #81b5a1; background-color: #283d40; font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; font-size: 10pt; color: #ffffff; height: 20px; } .SOKMKBArticle td { border-color: #81b5a1; margin: 5px 5px 5px 5px; font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; font-size: 10pt; color: #283d40; } .SOKMKBArticle p { color: #283d40; font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; } .SOKMKBArticle li { color: #283d40; font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; font-size: 10pt; line-height: 1.5; } .SOKMKBArticle pre { font-family: Courier New; } .SOKMKBArticle div { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; } .SOKMKBArticle hr { border-top-width: 1px; border-top-style: solid; border-top-color: #81b5a1; } .SOKMKBArticle a { color: #81b5a1; } .SOKMKBArticle a.two:link { padding: 15px 45px 15px 45px; margin-top: 20px; color: #ffffff; text-align: center; background-color: #1F8476; border: 1px solid; border-color: #1F8476; } .SOKMKBArticle a.two:visited { padding: 15px 45px 15px 45px; margin-top: 20px; color: #ffffff; text-align: center; background-color: #1F8476; border: 1px solid; border-color: #1F8476; } .SOKMKBArticle a.two:hover { color: #ffffff; background-color: #259b8a; } .SOKMKBArticle .button { padding: 15px 45px 15px 45px; margin-top: 20px; color: #ffffff; text-align: center; background-color: #1F8476; border: 1px solid; border-color: #1F8476; } .SOKMKBArticle .title { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #81b5a1; font-size: 30pt; } .SOKMKBArticle .hd1 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-size: 20pt; border-bottom: 1px solid; border-bottom-color: #81b5a1; text-decoration: none; } .SOKMKBArticle h1 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-size: 20pt; font-weight: normal; border-bottom: 1px solid; border-bottom-color: #81b5a1; text-decoration: none; } .SOKMKBArticle .hd2 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #68a1af; font-weight: bold; font-size: 16pt; text-decoration: none; } .SOKMKBArticle h2 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #68a1af; font-weight: bold; font-size: 16pt; font-weight: normal; text-decoration: none; } .SOKMKBArticle .hd3 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 14pt; text-decoration: none; } .SOKMKBArticle h3 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 14pt; text-decoration: none; } .SOKMKBArticle .hd4 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 12pt; text-decoration: none; } .SOKMKBArticle h4 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 12pt; text-decoration: none; } .SOKMKBArticle .hd5 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: bold; font-size: 10pt; text-decoration: bold; } .SOKMKBArticle h5 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: bold; font-size: 10pt; text-decoration: bold; } .SOKMKBArticle .hd6 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 10pt; text-decoration: underline; } .SOKMKBArticle h6 { font-family: Century Gothic, Verdana, Helvetica, Arial, sans-serif; color: #283d40; font-weight: normal; font-size: 10pt; text-decoration: underline; } .SOKMKBArticle details { font-size: 10pt; } .SOKMKBArticle details[open] summary ~ * { animation: sweep .5s; margin-top: 0; padding-top: 10px; } @keyframes sweep { 0% {opacity: 0; margin-top: -10px} 100% {opacity: 1; margin-top: 0px} } .SOKMKBArticle summary { cursor: pointer; outline: none; margin-bottom: 3px; } .SOKMKBArticle .summary { background-color: #81b5a1; font-size: 10px; color: white; cursor: pointer; padding: 5px; width: 100%; border: none; text-align: left; outline: none; vertical-align: top; } --> Table of Contents OverviewRequired PluginsTerraform Discovery - Linux ServerResourceBlock & API for Terraform Provision/DeprovisionTroubleshootingFAQs Overview This article is intend to provide the information on ServiceNow Discovery support for Terraform and configuration, currently ServiceNow provides supports the Terraform Discovery along with Provision/Deprovision operations for the customers, the configuration is only available in Cloud Admin Portal with Config Provider Terrform Configuration for Discovery: Terraform on WindowsTerraform on Linux Required Plugins Cloud Provisioning and Governance The Cloud Management plugin (com.snc.cloud.mgmt) is renamed the Cloud Provisioning and Governance plugin. Cloud Management Core The Cloud Management Core plugin (com.snc.cloud.core) is renamed the Cloud Provisioning and Governance Core plugin. Discovery The Discovery plugin is a perquisite for Cloud Provisioning and Governance Cloud Management Terraform Connector The ServiceNow® Terraform Connector app is available in the ServiceNow® Store. The app needs Cloud Provisioning and Governance plugin as dependency, provide a provisioning path into multiple cloud platform resources. Create service catalog offerings for Amazon AWS Cloud Microsoft Azure, VMware vSphere, and IBM Cloud Platform by importing Terraform config templates. Refer the below for more information on support for Terraform Connector Cloud Provisioning and Governance release notes Terraform Discovery - Linux Server Prerequisites All the above mentioned plugins must need to be activated The User need to have "cloud_admin" role associatedA MID Server available and reachable to the Terraform Linux host and the MID Server must have "Cloud Management" & "Terraform" Capabilities.The Terraform package installed on the Linux host should be either version 0.11 and 0.12 (Other versions are not yet supported) Configuration requirement on Linux Host Linux Host IP AddressThe Terraform Discovery only supports credentials with username & "SSH Private Key" configuration, it will not support username/password configurationPath to Terraform DirectoryThe Terraform Parent Directory should have the Folders with Filenames with extension ".tf", example as belowFrom the above example, the Parent Path is "/Terraform" which has a Sub Directory VMWARE, the SubDirectory has a file with extension ".tf", in this case only VMWARE Directory will be Discovered and the rest are ignored. Terraform Discovery Configuration on ServiceNow Instance Login to ServiceNow InstanceNavigator >> Credentials >> Create New Credentials >> Choose "SSH Private Key" >> Provide Username/Private keyNavigate to "Cloud Admin Portal"Cloud Admin Portal >> Manage >> Config Management Config Management >> Config Provider >> Click on New and fill the details Click Submit Once the Provider has been created, open the record and Click on "Discover Now" ResourceBlock & API for Terraform ResourceBlock Cloud Admin PortalDesign >> ResourceBlock Search for Terraform and observe 2 ResourceBlocks, Terraform for Linux and Terraform Enterprise for Windows There will be only one Interface with one Step, the input Parameters are preconfigured Cloud API for Terraform Cloud Admin PortalDesignCloud API >> API Search for Terraform 4 Method Mappers Actions Execute Command >> DiscoveryProvision >> Provisioning Deprovision >> DeprovisionGetState >> Post Provision The Provision/Deprovision/Getstate are currently dummy as the actions would go through respective CloudProvider APIs, for example: Provisioning Azure VM from Terraform would execute API from AzureDatacenter ResourceBlock. Script Includes & Response Processor Execute Command: https://<InstanceName>.service-now.com/nav_to.do?uri=ecc_agent_script_include.do?sys_id=0245ae970b4033000635a387b6673a36 Discovery Response Processor: https://<InstanceName>.service-now.com/nav_to.do?uri=sn_cmp_rb_resourcescript.do?sys_id=e5d872890b8c33007a48403f15673a9b%26sysparm_view=rbUiView Provision/Deprovision Process Once a Catalog created from Terraform, the provision would have the Datacenter configuration (Azure/Vmware)The Provision or Deprovision would take place according to the Dataceneter and Cloud Provider Once a VM is provisioned using the Terraform Config, both the Provision/Deprovision would go through the same Terraform config If in case the Provision was successful and the Terraform Server is not available, the Deprovision would also fail until the Terraform Server is available Simple Test to Provision TF for Azure on Terraform host Manually, log in to terraform provider box (starts with ip 172.XX.XX.XX) with the credentials mentioned in 'Terraform' credentials record (ec2-user and private key). Use these credentials only.Open the terminalExecute command:export HISTCONTROL=ignorespace\n printf ' %s' 'tenantId = <quote>'abcdef-ghijk-1234-567899'<quote>\n' >> /tmp/props.tfvars"Navigate to /tmp directory and check if the file props.tfvars is created with string : tenantId = <quote>'abcdef-ghijk-1234-567899'<quote>OR (if the above doesn't create a file)Execute command: sudo export HISTCONTROL=ignorespace\n printf ' %s' 'tenantId = <quote>'abcdef-ghijk-1234-567899'<quote>\n' >> /tmp/props.tfvars"Navigate to /tmp directory and check if the file props.tfvars is created with string : tenantId = <quote>'abcdef-ghijk-1234-567899'<quote> Performance Troubleshooting Logs As the Terraform Discovery is still CAPI based, below tables are involved to troubleshoot further sn_cmp_order sn_capi_api_trailMID Logs wf_context Knowledge Articles and Known PRBs In Progress FAQs Terraform Supported Version As per documentation you are only supporting 0.11v and 0.12v. Yes, Currently, Terraform is supported for 0.11v and 0.12v. Terraform started deprecating O.11v in 2019. Yes, ServiceNow Roadmap to support V1 The latest version is 0.15 and ServiceNow still doesn't support it ServiceNow does not intend to support dot-versions (0.14/0.15) since the official v1 is out now offering better stability of state formats. When would Servicenow Support V1? Support for Terraform version 1 is planned in Q1 2022 timeframe. Additional Information