不能污染null_resource



我得到Terraform 0.11.11。该图显示说话中的资源在root模块

$ 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.

更新

$ terraform state list|grep resolv_conf 
null_resource.service_resolv_conf[0] 
null_resource.service_resolv_conf[1] 

然后我尝试了:

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

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

terraform graph赋予您有关资源及其关系的全部图片。

,但这不是故障排除并了解Terraform *.tfstate文件中命名的好命令。

我建议使用terraform state list运行,然后您可以很容易地知道如何污染列表中的一个资源。

terraform state list
terraform taint <copy resource directly from above list>

对于那些进入此线程的人寻找Terraform Taint/untaint null_resource,Terraform错误与The resource […] couldn't be found in the module root一起出现的是 @victor-m在 @victor-m上发布的正确和工作答案,无法Taint null_resource

terraform taint -module=name null_resource.name

untaint命令相同。

毕竟我发现了解决方案

出现,然后在基于列表的连接中有更多主机(使用的"计数")

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!

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

最新更新