在 Terraform OCI 上需要帮助

Need help on Terraform OCI

我正在尝试在 OCI 上学习 terraform,我在我的 terraform-code.tf 文件中编写了一个小代码来创建一个块实例,但是当我 运行 我得到的 terraform 计划以下错误。

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" {

我试图从我的 windows 机器上 ping identity.var.region.oraclecloud.com 但没有成功

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

我认为这是代理的问题,由于某种原因我无法访问 identity.var.region.oraclecloud.com

我在 github 上找到了一篇类似的文章:https://github.com/terraform-providers/terraform-provider-oci/issues/960

谁能帮我解决这个问题?

回答我自己的问题,对 identity.var.region.oraclecloud.com 的 ping 测试无关紧要。

如果您收到以下错误,很可能是您没有在所需变量中正确传递您的区域 ocid。要排除故障,您可以将变量替换为双引号中的实际 OCID 作为字符串 ""

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" {

对我来说问题是, 我错误地传递了变量信息。 使用 TF 0.11 变量信息设置如下 tenancy_ocid = "${var.tenancy_ocid}" 使用 TF 0.13 变量信息设置如下 tenancy_ocid = "${var.tenancy_ocid}"(旧方法仍然有效,但您会收到警告)

或者为了进行故障排除,您可以简单地使用 tenancy_ocid = ""

我刚刚开始使用 OCI 学习 terraform,周围没有太多有用的帖子。

var.region 是一个变量,应该被替换。您无法访问 https://identity.var.region.oraclecloud.com 是正常的,因为它不存在。这是一个list of the existing regions.

有效 url 例如 https://identity.us-ashburn-1.oraclecloud.com