InvalidVpcID.NotFound while VPC is created

I have a fairly simple Terraform script for AWS, based on an example from the terraform site. Whenever I run this I get an error:

Error: error attaching EC2 Internet Gateway (igw-xxxxx): Error attaching internet gateway: InvalidVpcID.NotFound: The vpc ID '' does not exist status code: 400, request id: xxxx

The Terraform console log before it, does show the creation of the vpc:

ws_internet_gateway.default: Creating…
aws_vpc.test: Creating… Creating…
aws_vpc.test: Creation complete after 2s [id=vpc-xxxx] Still creating… [10s elapsed] Still creating… [20s elapsed] Still creating… [30s elapsed] Creation complete after 32s [id=i-xxxx]

And when I check the state with terraform state show 'aws_vpc.test' it returns the proper segment with ID. In the AWS console I can see that the VPC has been created. So I am a bit at a loss what is wrong here? :no_mouth:


  • Terraform: v0.12.20
  • AWS provider: v2.48.0
  • On OSX 10.15.2

Script as used (region is set the eu-central-1, and stripped down so the created VPC & gateway are not used):

provider "aws" {
  profile    = "default"
  region     = var.region

# Create a VPC to launch our instances into
resource "aws_vpc" "test" {
  cidr_block = ""
  assign_generated_ipv6_cidr_block = true

  tags = {
    Name = "test"

# Create an internet gateway to give subnet access to the outside world
resource "aws_internet_gateway" "default" {
  vpc_id = ""

resource "aws_instance" "dev" {
  ami           = var.amis[var.region]
  instance_type = "t2.micro"

I can provide the answer myself:
vpc_id = "" should read vpc_id = without the quotes.

When starting with a 0.11 version I misinterpreted the error: Terraform 0.11 and earlier required all non-constant expressions to be provided via interpolation syntax, but this pattern is now deprecated. To silence this warning, remove the "${ sequence from the start and the }" sequence from the end of this expression, leaving just the inner expression.

Ah well…