Home > Blockchain >  Terraform - Error creating NAT Gateway: InvalidElasticIpID.Malformed
Terraform - Error creating NAT Gateway: InvalidElasticIpID.Malformed

Time:12-16

I want to use Terraform to create a VPN with a fixed public IP address that I can assign to our Lambda functions.

I found this blog post and code that does this:

However, when I run the script I get this error:

│ 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" {

This is the content of the natgateway.tf file:

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]
}

Things I tried:

Any clue or something in the scripts that I need to change?

CodePudding user response:

There are strings with mistakes in natgateway.tf. The corrected version is:

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]
}

Please note that I do not check the validity of the VPC or its other resources. I'm just addressing the error you've reported.

  • Related