Terraform 创建 EKS 集群后,下一个计划看到子网对标签的更改
After EKS cluster is created by Terraform, next plan sees subnet changes to tags
我打算使用 Terraform 在 AWS 中建立我的整个监控基础设施。
到目前为止,在我的 Terraform 项目中已经创建了 VPC、子网和适当的安全组。我尽可能使用 Terraform Registry:
我看到的问题是,在部署 EKS 集群后,它向 VPC 和子网引入了 Terraform 似乎不知道的标签。因此下一次 terraform plan
是 运行 它识别它不管理的标签并打算删除它们:
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ module.vpc.aws_subnet.private[0]
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
~ module.vpc.aws_subnet.private[1]
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
~ module.vpc.aws_vpc.this
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
Plan: 0 to add, 3 to change, 0 to destroy.
------------------------------------------------------------------------
terraform-provider-aws with a local workaround using bash 有一个未解决的问题,但有谁知道如何让 Terraform 意识到这些标签或让后续计划以稳健的方式忽略它们?
如果你控制了模块,你可以尝试在lifecycle
块中使用ignore_changes
子句。像
lifecycle {
ignore_changes = [
"tags"
]
}
使用您无法控制的模块会更加棘手。
只需在调用模块时添加标签,请注意在 https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/1.41.0 的示例中它会在那里显示标签,而在文档中它会显示 "A map of tags to add to all resources" 以便您可以将其添加到该地图。
所以最后我们选择了完全不使用terraform来部署集群,
相反,我们使用 eksctl
来自 Weaveworks 的基于社区的工具。
我们在伦敦的 AWS 办公室进行一些培训时,一位 AWS 解决方案架构师推荐了它。
如果需要,配置可以存储在源代码管理中。
eksctl create cluster -f cluster.yaml
由于 EKS 对基础设施做了很多标记,现在我们的生活好多了,状态文件不再抱怨标记。
我打算使用 Terraform 在 AWS 中建立我的整个监控基础设施。 到目前为止,在我的 Terraform 项目中已经创建了 VPC、子网和适当的安全组。我尽可能使用 Terraform Registry:
我看到的问题是,在部署 EKS 集群后,它向 VPC 和子网引入了 Terraform 似乎不知道的标签。因此下一次 terraform plan
是 运行 它识别它不管理的标签并打算删除它们:
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ module.vpc.aws_subnet.private[0]
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
~ module.vpc.aws_subnet.private[1]
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
~ module.vpc.aws_vpc.this
tags.%: "4" => "3"
tags.kubernetes.io/cluster/monitoring: "shared" => ""
Plan: 0 to add, 3 to change, 0 to destroy.
------------------------------------------------------------------------
terraform-provider-aws with a local workaround using bash 有一个未解决的问题,但有谁知道如何让 Terraform 意识到这些标签或让后续计划以稳健的方式忽略它们?
如果你控制了模块,你可以尝试在lifecycle
块中使用ignore_changes
子句。像
lifecycle {
ignore_changes = [
"tags"
]
}
使用您无法控制的模块会更加棘手。
只需在调用模块时添加标签,请注意在 https://registry.terraform.io/modules/terraform-aws-modules/vpc/aws/1.41.0 的示例中它会在那里显示标签,而在文档中它会显示 "A map of tags to add to all resources" 以便您可以将其添加到该地图。
所以最后我们选择了完全不使用terraform来部署集群,
相反,我们使用 eksctl
来自 Weaveworks 的基于社区的工具。
我们在伦敦的 AWS 办公室进行一些培训时,一位 AWS 解决方案架构师推荐了它。
如果需要,配置可以存储在源代码管理中。
eksctl create cluster -f cluster.yaml
由于 EKS 对基础设施做了很多标记,现在我们的生活好多了,状态文件不再抱怨标记。