Terraform - 创建 NAT 网关时出错:InvalidElasticIpID.Malformed
Terraform - Error creating NAT Gateway: InvalidElasticIpID.Malformed
我想使用 Terraform 创建一个具有固定 public IP 地址的 VPN,我可以将其分配给我们的 Lambda 函数。
我找到了这个博客 post 和执行此操作的代码:
- 博客post:https://jaffarshaik.medium.com/implementing-vpc-architecture-using-terraform-3de6c42d7646
- Github: https://github.com/Jaffarterraform786/vpc
但是,当我 运行 脚本时,我得到了这个错误:
│ Error: Error creating NAT Gateway: InvalidElasticIpID.Malformed: The elastic-ip ID 'aws_eip.ip.id' is malformed
│ status code: 400, request id: 96b26796-931d-4470-85b5-5c46c39889a9
│
│ with aws_nat_gateway.natgateway,
│ on natgateway.tf line 1, in resource "aws_nat_gateway" "natgateway":
│ 1: resource "aws_nat_gateway" "natgateway" {
这是 natgateway.tf 文件的内容:
resource "aws_nat_gateway" "natgateway" {
allocation_id = "aws_eip.ip.id"
subnet_id = "aws_subnet.publicsubnet.id"
tags = {
name = "prod nategatway"
}
depends_on = [aws_eip.eip]
}
我尝试过的事情:
- 运行 在没有创建其他 VPC 的干净区域上的脚本 - 仍然没有工作
- 在 Github 上提出了一个问题:https://github.com/Jaffarterraform786/vpc/issues/2
- 运行 Terraform 检查程序以查看是否有任何错误,none 找到了。
我需要更改脚本中的任何线索或其他内容吗?
natgateway.tf
中有错误的字符串。更正版本为:
resource "aws_nat_gateway" "natgateway" {
allocation_id = aws_eip.eip.id
subnet_id = aws_subnet.publicsubnet.id
tags = {
name = "prod nategatway"
}
depends_on = [aws_eip.eip]
}
请注意,我不检查 VPC 或其其他资源的有效性。我只是在解决您报告的错误。
我想使用 Terraform 创建一个具有固定 public IP 地址的 VPN,我可以将其分配给我们的 Lambda 函数。
我找到了这个博客 post 和执行此操作的代码:
- 博客post:https://jaffarshaik.medium.com/implementing-vpc-architecture-using-terraform-3de6c42d7646
- Github: https://github.com/Jaffarterraform786/vpc
但是,当我 运行 脚本时,我得到了这个错误:
│ Error: Error creating NAT Gateway: InvalidElasticIpID.Malformed: The elastic-ip ID 'aws_eip.ip.id' is malformed
│ status code: 400, request id: 96b26796-931d-4470-85b5-5c46c39889a9
│
│ with aws_nat_gateway.natgateway,
│ on natgateway.tf line 1, in resource "aws_nat_gateway" "natgateway":
│ 1: resource "aws_nat_gateway" "natgateway" {
这是 natgateway.tf 文件的内容:
resource "aws_nat_gateway" "natgateway" {
allocation_id = "aws_eip.ip.id"
subnet_id = "aws_subnet.publicsubnet.id"
tags = {
name = "prod nategatway"
}
depends_on = [aws_eip.eip]
}
我尝试过的事情:
- 运行 在没有创建其他 VPC 的干净区域上的脚本 - 仍然没有工作
- 在 Github 上提出了一个问题:https://github.com/Jaffarterraform786/vpc/issues/2
- 运行 Terraform 检查程序以查看是否有任何错误,none 找到了。
我需要更改脚本中的任何线索或其他内容吗?
natgateway.tf
中有错误的字符串。更正版本为:
resource "aws_nat_gateway" "natgateway" {
allocation_id = aws_eip.eip.id
subnet_id = aws_subnet.publicsubnet.id
tags = {
name = "prod nategatway"
}
depends_on = [aws_eip.eip]
}
请注意,我不检查 VPC 或其其他资源的有效性。我只是在解决您报告的错误。