我得到了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.更新
$ 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.发布于 2019-03-12 01:23:10
毕竟我找到了解决方案
它出现了,然后当有更多的主机在基于列表的连接中(使用'count')
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!瞧!
我不可能在文档中找到这一点。希望这对某些人有帮助。
发布于 2019-03-07 07:56:40
terraform graph为您提供了有关资源及其关系的完整图景。
但它不是一个很好的命令,用于排除故障和了解资源在terraform *.tfstate文件中的命名方式。
我建议使用terraform state list运行,这样你就可以很容易地知道如何污染列表中的某个资源。
terraform state list
terraform taint <copy resource directly from above list>发布于 2020-06-26 23:38:21
对于那些来到这个帖子寻找terraform污点/未污点null_resource的人,这里有@victor-m在Cannot taint null_resource上发布的正确且有效的答案
terraform taint -module=name null_resource.nameuntaint命令也是如此。
https://stackoverflow.com/questions/55029041
复制相似问题