Search code examples
terraformoracle-cloud-infrastructure

Need help on Terraform OCI


I am trying to learn terraform on OCI, I have written a small code to in my terraform-code.tf file to create a block instance, however when I run the terraform plan I get the following error.

data "oci_identity_availability_domain" "ad" {
  compartment_id = "var.tenancy_ocid"
}

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.oci_identity_availability_domain.ad: Refreshing state...

Error: Get https://identity.var.region.oraclecloud.com/20160918/availabilityDomains?compartmentId=ocid1.tenancy.oc1..aaaaaaaa35fzgotfw445uiswdvjcxnxitafa4scy4dmcuifrvvzkxylqga3q: dial tcp: lookup identity.var.region.oraclecloud.com: no such host

  on terraform-code.tf line 46, in data "oci_identity_availability_domain" "ad":
  46: data "oci_identity_availability_domain" "ad" {

I tried to ping identity.var.region.oraclecloud.com from my windows machine but no luck

ping identity.var.region.oraclecloud.com
Ping request could not find host identity.var.region.oraclecloud.com. Please check the name and try again.

I believe this is an issue with the proxy where for some reason I am unable to reach identity.var.region.oraclecloud.com

I found a similar article on github : https://github.com/terraform-providers/terraform-provider-oci/issues/960

Can anyone help me to resolve this issue ?


Solution

  • To answer my own question, the ping test to identity.var.region.oraclecloud.com does not matter.

    If you receive the below error most probably you are not passing your region ocid correctly in the required variables. To troubleshoot you can replace the variables with the actual OCID in double quotes as a string ""

    Error: Get https://identity.var.region.oraclecloud.com/20160918/availabilityDomains?compartmentId=ocid1.tenancy.oc1..aaaaaaaa35fzgotfw445uiswdvjcxnxitafa4scy4dmcuifrvvzkxylqga3q: dial tcp: lookup identity.var.region.oraclecloud.com: no such host
    
      on terraform-code.tf line 46, in data "oci_identity_availability_domain" "ad":
      46: data "oci_identity_availability_domain" "ad" {
    

    For me the issue was, I was passing the variable information incorrectly. With TF 0.11 variable information is set like tenancy_ocid = "${var.tenancy_ocid}" With TF 0.13 variable information is set like tenancy_ocid = "${var.tenancy_ocid}" ( the old way would still work but you will receive a warning)

    Or for troubleshooting you can simply use tenancy_ocid = ""

    I have just started to learn terraform with OCI and there are not many helpful posts around.