Getting error while executing Terraform script in ServiceNow

Venkatesh S5
Kilo Contributor

Hello Team,

While we are trying to launch launch stack (Terraform code) in ServiceNow, it ends up with "  Failed to execute API - Please input value for credential field(s) -UserName, Password. (script_include:TerraformExecutor; line 56)".

Note: We have updated the credentials in Cloud admin portal already. 

Please feel free to share your thoughts for further analysis. 

1 ACCEPTED SOLUTION

Ram Devanathan1
ServiceNow Employee
ServiceNow Employee

you need to modify the terraform files to add empty vars like this into the vars.tf -

#File =vars.tf
variable "vsphere_user" {}
variable "vsphere_password" {}
variable "vsphere_server" {}

and reference these vars in your provider block -

#File =provider.tf
# Configure the VMware vSphere Provider
provider "vsphere" {
 user = var.vsphere_user
 password = var.vsphere_password
 vsphere_server = var.vsphere_server
 # if you have a self-signed cert
 allow_unverified_ssl = true
}

for azure and aws this can be different, just look at standard provider block documentation for each provider and setup vars like this.

Once this is done, CPG will ensure that the creds are passed at runtime into the vars to eventually be used by Terraform.

you can look for reference / examples here -

https://github.com/MasterChefCloudMgmt

View solution in original post

11 REPLIES 11

Prasad Pagar
Mega Sage

Hi @Venkatesh S 

Did you check that Script include(Terraform Executor) mention and what is line 56?

Is it picking credentials from somewhere?

Thank you
Prasad

Hello Prasad,

 

Thanks for your response. 

Yes. I have validated it. Actually I am getting this error for all of my Terraform scripts. Herewith attached one of the script which i have been using it. 

 

Note : As I am new Terraform/CPG modules, I have hardcoded the credentials as part of testing purpose. 

Ram Devanathan1
ServiceNow Employee
ServiceNow Employee

you need to modify the terraform files to add empty vars like this into the vars.tf -

#File =vars.tf
variable "vsphere_user" {}
variable "vsphere_password" {}
variable "vsphere_server" {}

and reference these vars in your provider block -

#File =provider.tf
# Configure the VMware vSphere Provider
provider "vsphere" {
 user = var.vsphere_user
 password = var.vsphere_password
 vsphere_server = var.vsphere_server
 # if you have a self-signed cert
 allow_unverified_ssl = true
}

for azure and aws this can be different, just look at standard provider block documentation for each provider and setup vars like this.

Once this is done, CPG will ensure that the creds are passed at runtime into the vars to eventually be used by Terraform.

you can look for reference / examples here -

https://github.com/MasterChefCloudMgmt

Hello Sir,

 

Thank you for your assistance. I have done with Provider & Vars and validated. It got success when I tried from Visual studio but when I try the same code in ServiceNow it ends up with the same error.