无法污染null_resource

时间:2019-03-06 17:33:41

标签: terraform

我得到了Terraform 0.11.11。 该图显示正在讲话的资源在根模块中

$ terraform graph
digraph {
        compound = "true"
        newrank = "true"
        subgraph "root" {
                "[root] data.template_file.default" [label = "data.template_file.default", shape = "box"]
                "[root] data.template_file.etcd" [label = 
...
                "[root] null_resource.service_resolv_conf" [label = "null_resource.service_resolv_conf", shape = "box"]
...

但是试图对其进行污染的事实并非如此:

$ terraform taint null_resource.service_resolv_conf
The resource null_resource.service_resolv_conf couldn't be found in the module root.

3 个答案:

答案 0 :(得分:1)

background-color:rgb(255, 255, 255); border-bottom-color:rgb(255, 255, 255); border-bottom-left-radius:0px; border-bottom-right-radius:0px; border-bottom-style:solid; border-bottom-width:1px; border-image-outset:0px; border-image-repeat:stretch; border-image-slice:100%; border-image-source:none; border-image-width:1; border-left-color:rgb(255, 255, 255); border-left-style:solid; border-left-width:1px; border-right-color:rgb(255, 255, 255); border-right-style:solid; border-right-width:1px; border-top-color:rgb(255, 255, 255); border-top-left-radius:0px; border-top-right-radius:0px; border-top-style:solid; border-top-width:1px; box-sizing:border-box; color:rgb(0, 0, 0); cursor:text; display:inline-block; font-family:azo-sans-web, sans-serif; font-size:16px; font-stretch:100%; font-style:normal; font-variant-caps:normal; font-variant-east-asian:normal; font-variant-ligatures:normal; font-variant-numeric:normal; font-weight:400; height:72px; letter-spacing:0.56px; line-height:22.8571px; margin-bottom:0px; margin-left:0px; margin-right:0px; margin-top:0px; outline-color:rgb(0, 0, 0); outline-style:none; outline-width:0px; padding-bottom:24px; padding-left:24px; padding-right:24px; padding-top:24px; text-align:center; text-indent:0px; text-rendering:auto; text-shadow:none; text-transform:none; width:702px; word-spacing:0px; writing-mode:horizontal-tb; -webkit-appearance:none; -webkit-box-direction:normal; -webkit-rtl-ordering:logical; -webkit-border-image:none; 为您提供了有关资源及其关系的全貌。

但这不是进行故障排除并了解​​如何在terraform terraform graph文件中命名资源的好命令。

我建议使用*.tfstate,这样您就可以轻松地知道如何污染列表中的资源之一。

terraform state list

答案 1 :(得分:0)

毕竟我找到了解决办法

它出现,然后当基于列表的连接中有更多主机时(使用“计数”)

resource "null_resource" "provision_docker_registry" {
  count      = "${length(local.service_vms_names)}"
  depends_on = ["null_resource.service_resolv_conf"]

  connection {
    user        = "cloud-user"
    private_key = "${file("${path.module}/../ssh/${var.os_keypair}.pem")}"
    host        = "${element(local.service_fip, count.index)}"
  }

通过在点后指定索引来污染资源,即

$ terraform taint null_resource.provision_docker_registry.0
The resource null_resource.provision_docker_registry.0 in the module root has been marked as tainted!

Voila!

我在文档中找不到该内容。希望这对某人有帮助。

答案 2 :(得分:0)

对于谁进入此线程寻找地形污染/未污染null_resource的人,这里的The resource […] couldn't be found in the module root出现地形错误,这是@ victor-m在Cannot taint null_resource发表的正确且有效的答案< / p>

terraform taint -module=name null_resource.name

untaint命令相同。