hashicorp/terraform — pull request #585 by fdr (2014-11-20 06:04:02+00:00)
Title: Make Routes in RouteTable optional

Otherwise it is impossible to get simple configurations with the
"default" routing table, which is only the "local" route.

The following contents of main.tf expose the bug, and boots an instance
fine after this patch is applied:

variable aws_access_key {}
variable aws_secret_key {}
variable aws_ubuntu_ami {}

provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "us-east-1"
}

resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/20"
}

resource "aws_route_table" "private" {
vpc_id = "${aws_vpc.default.id}"
# Note the lack of "route" sub-key here.
}

resource "aws_subnet" "private" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "10.0.1.0/24"
}

resource "aws_route_table_association" "private" {
subnet_id = "${aws_subnet.private.id}"
route_table_id = "${aws_route_table.private.id}"
}

# Demonstrate an instance can be booted fine in this fashion.
resource "aws_instance" "sample" {
ami = "${var.aws_ubuntu_ami}"
instance_type = "t2.micro"
subnet_id = "${aws_subnet.private.id}"
}

terraform.tfvars for completeness:

aws_access_key = "..."
aws_secret_key = "..."

# A public Trusty AMI
aws_ubuntu_ami = "ami-9aaa1cf2"