【问题标题】:Need help on Terraform OCI在 Terraform OCI 上需要帮助
【发布时间】:2020-11-23 23:28:57
【问题描述】:

我正在尝试在 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

谁能帮我解决这个问题?

【问题讨论】:

  • 您将文字字符串 "var.tenancy_ocid" 作为参数传递给 compartment_id 。您的意思是传递tenancy_ocid 变量的值吗?
  • 嗨蒙哥马利,谢谢您的回复。是的,我后来想通了。实际上问题出在 TF 0.11 上,我们需要使用类似“${var.tenancy_ocid}”这样的变量,这在我使用 0.13.5 的当前版本的 terraform 中已经过时,因此我试图找到完全替换它应该只是 var.tenancy_ocid 而不是“var.tenancy_ocid”
  • 变量 var.region 没有被它的值替代。你申报了吗?它应该被类似 us-ashburn-1 的东西取代以形成正确的 url:https://identity.us-ashburn-1.oraclecloud.com

标签: terraform oracle-cloud-infrastructure


【解决方案1】:

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

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

【讨论】:

  • 嗨杰罗姆,问题是我的 var.region 没有被我的 terraform 代码中的 us-ashburn-1 取代,因此我遇到了这个问题。
【解决方案2】:

为了回答我自己的问题,对 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,周围没有很多有用的帖子。

【讨论】:

    猜你喜欢
    • 2021-07-29
    • 2011-07-10
    • 2011-06-23
    • 2014-11-04
    • 1970-01-01
    • 2022-08-21
    • 1970-01-01
    • 2019-03-26
    • 1970-01-01
    相关资源
    最近更新 更多