Created
July 2, 2015 03:51
-
-
Save pikeas/e5d1f1caf96d8689a588 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"variable": { | |
"region": { | |
"default": "us-east-1" | |
}, | |
"key_name": {}, | |
"vpc_cidr": { | |
"default": "11.0.0.0/16" | |
}, | |
"zones": { | |
"default": 2 | |
}, | |
"zone_names": { | |
"default": { | |
"0": "a", | |
"1": "b" | |
} | |
}, | |
"public_cidrs": { | |
"default": { | |
"0": "11.0.253.0/24", | |
"1": "11.0.254.0/24" | |
} | |
}, | |
"private_cidrs": { | |
"default": { | |
"0": "11.0.1.0/24", | |
"1": "11.0.2.0/24" | |
} | |
} | |
}, | |
"resource": { | |
"aws_vpc": { | |
"main": { | |
"cidr_block": "${var.vpc_cidr}", | |
"enable_dns_hostnames": true | |
} | |
}, | |
"aws_internet_gateway": { | |
"main": { | |
"vpc_id": "${aws_vpc.main.id}" | |
} | |
}, | |
"aws_subnet": { | |
"public": { | |
"count": "${var.zones}", | |
"vpc_id": "${aws_vpc.main.id}", | |
"cidr_block": "${lookup(var.public_cidrs, count.index)}", | |
"availability_zone": "${var.region}${lookup(var.zone_names, count.index)}", | |
"map_public_ip_on_launch": true, | |
"depends_on": [ | |
"aws_internet_gateway.main" | |
] | |
}, | |
"private": { | |
"count": "${var.zones}", | |
"vpc_id": "${aws_vpc.main.id}", | |
"cidr_block": "${lookup(var.private_cidrs, count.index)}", | |
"availability_zone": "${var.region}${lookup(var.zone_names, count.index)}" | |
} | |
}, | |
"aws_route_table": { | |
"public": { | |
"vpc_id": "${aws_vpc.main.id}", | |
"route": { | |
"cidr_block": "0.0.0.0/0", | |
"gateway_id": "${aws_internet_gateway.main.id}" | |
} | |
}, | |
"private": { | |
"vpc_id": "${aws_vpc.main.id}", | |
"route": { | |
"cidr_block": "0.0.0.0/0", | |
"instance_id": "${aws_instance.bastion_nat.id}" | |
} | |
} | |
}, | |
"aws_route_table_association": { | |
"public": { | |
"count": "${var.zones}", | |
"subnet_id": "${element(aws_subnet.public.*.id, count.index)}", | |
"route_table_id": "${aws_route_table.public.id}" | |
}, | |
"private": { | |
"count": "${var.zones}", | |
"subnet_id": "${element(aws_subnet.public.*.id, count.index)}", | |
"route_table_id": "${aws_route_table.private.id}" | |
} | |
}, | |
"aws_instance": { | |
"bastion_nat": { | |
"ami": "ami-303b1458", | |
"instance_type": "t2.micro", | |
"subnet_id": "${aws_subnet.public.0.id}", | |
"source_dest_check": false, | |
"key_name": "${var.key_name}" | |
} | |
} | |
} | |
}% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment