在module.eip中尚未声明托管资源“ aws_internet_gateway”“ igw_id”

时间:2020-11-12 09:25:59

标签: amazon-web-services terraform

我正在尝试使用terraform创建eip和natgateway,但遇到了以下错误。

Error: Reference to undeclared resource

  on ../../modules/eip/main.tf line 7, in resource "aws_eip" "nat-gateway":
   7:   depends_on = [aws_internet_gateway.igw_id]

A managed resource "aws_internet_gateway" "igw_id" has not been declared in
module.eip.

这是我的main.tf

variable "igw_id" {}

resource "aws_nat_gateway" "nat-gateway" {
  allocation_id = "*********"
  subnet_id     = "*********"
  depends_on    = [aws_internet_gateway.igw_id]

  tags {
    Name        = "*********"
    Service     = "*********"
    Environment = terraform.workspace
  }
}

有人可以帮助我吗?

这是我的igw.tf

resource "aws_internet_gateway" "igw" {
  vpc_id = "********"
  tags = {
    Name        = "*********"
    Service     = "*********"
    Environment = terraform.workspace
  }
}

output.tf

output igw_id {
  value = aws_internet_gateway.igw.id
}

0 个答案:

没有答案