英文:
Terraform migration from v0.11 to v0.12 problem with tags
问题
我正在尝试将我的 Terraform 计划从 v0.11 迁移到 v0.12 版本的 Terraform,并且在执行验证时,我遇到了相同错误的一些错误:“不受支持的块类型”,服务将问题标记在“TAGS”标记中,并附上了以下评论:
> 不应在此处使用类型为“tags”的块。您是不是想定义参数“tags”?如果是,请使用等号为其分配一个值。
一个示例就是这个有问题的资源:
resource "aws_vpc" "VPC" {
cidr_block = "10.0.0.0/24"
enable_dns_hostnames = "true"
enable_dns_support = "true"
tags {
Name = "${var.name}-VPC-Default"
Environment = var.env
Region = var.region
}
}
我在文档中阅读了关于这个资源的信息,它支持标记类型“TAGS”,并且在 v0.11 版本中可以正常工作。
关于我的问题,有什么建议吗?
英文:
I'm trying migrate my terraform plan from v0.11 to v0.12 terraform version and when I execute the validation I have some error with the same error : "Unsupported block type" and the service mark the trouble into the "TAGS" tag with that comment:
>Blocks of type "tags" are not expected here. Did you mean to define argument "tags"? If so, use the equals sign to assign it a value.
One example it's this troubling resource:
resource "aws_vpc" "VPC" {
cidr_block = "10.0.0.0/24"
enable_dns_hostnames = "true"
enable_dns_support = "true"
tags {
Name = "${var.name}-VPC-Default"
Environment = var.env
Region = var.region
}
}
I read into the documentation about this resource that support tag type "TAGS" and into the v0.11 version it's working fine.
Any suggestion about what it's my problem?
答案1
得分: 3
错误说明在Terraform 0.12中,tags
不再是一个块,而是一个参数。Terraform中的块看起来像:
block { ... }
这就是你当前的tags
看起来的方式。参数看起来像:
argument = value
因此,你需要将你的tags
从块转换为参数。可以像下面这样完成:
tags = {
Name = "${var.name}-VPC-Default"
Environment = var.env
Region = var.region
}
其中,tags
现在被赋予了你以前在块内包含的map
值。
英文:
The error is explaining that in Terraform 0.12 tags
are no longer a block, but rather now an argument. A block in Terraform appears like:
block { ... }
which is how your tags currently appear. An argument appears like:
argument = value
Therefore, you need to convert your tags
from a block to an argument. That can be done like the following:
tags = {
Name = "${var.name}-VPC-Default"
Environment = var.env
Region = var.region
}
where tags
is now being assigned the map
value you formerly contained within your block.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论