Terraform aws_eip 资源获取不可配置属性的值“错误”

Aci*_*ire 5 amazon-web-services terraform hashicorp

我是 Terraform 的新手,正在学习有关如何创建 aws_elasticip 模块的教程。当我执行“terraform plan”时,出现此问题,并且我无法继续创建 terraform 文件。

\n
 terraform {\n  required_providers {\n    aws = {\n      source  = "hashicorp/aws"\n      version = "~> 4.16"\n    }\n  }\n}\n\nprovider "aws" {\n  region = "eu-west-2"\n}\n\nresource "aws_eip" "lb" {\n  domain = "vpc"\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我还尝试使用声明的实例变量来执行此操作,但错误仍然存​​在

\n
terraform {\n  required_providers {\n    aws = {\n      source  = "hashicorp/aws"\n      version = "~> 4.16"\n    }\n  }\n}\n\nprovider "aws" {\n  region = "eu-west-2"\n}\n\nresource "aws_vpc" "vpc_a" {\n  cidr_block = "10.0.0.0/16"\n}\n\nresource "aws_instance" "server_a" {\n    ami = "ami-06464c878dbe46da4"\n    instance_type = "t2.micro"\n}\n\nresource "aws_eip" "lb" {\n    instance = aws_instance.server_a.id\n    domain = "vpc"\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我收到的错误如下。

\n
\xe2\x94\x82 Error: Value for unconfigurable attribute\n\xe2\x94\x82 \n\xe2\x94\x82   with aws_eip.lb,\n\xe2\x94\x82   on main.tf line 25, in resource "aws_eip" "lb":\n\xe2\x94\x82   25:     domain = "vpc"\n\xe2\x94\x82 \n\xe2\x94\x82 Can't configure a value for "domain": its value will be decided\n\xe2\x94\x82 automatically based on the result of applying this configuration.\n
Run Code Online (Sandbox Code Playgroud)\n

Mat*_*ard 10

您在提供程序块的配置中提供的语义版本控制规范解析~> 4.16>= 4.16 < 5.0.0. 在版本 5.0.0中,参数domain从资源中的属性迁移Computed到输入属性,作为参数的伪替换。您需要将 AWS 提供商至少升级到 5.0.0 才能使用此参数。aws_eipvpc