Skip to content

Instantly share code, notes, and snippets.

@f440
Created June 23, 2015 14:48
Show Gist options
  • Save f440/61c0379860a9c12998f3 to your computer and use it in GitHub Desktop.
Save f440/61c0379860a9c12998f3 to your computer and use it in GitHub Desktop.
Terraform Template
terraform.tfstate*
variable "name" {
default = "asdf"
}
provider "aws" {
region = "ap-northeast-1"
}
resource "aws_vpc" "default" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
tags {
Name = "${var.name}"
}
}
resource "aws_subnet" "default1" {
vpc_id = "${aws_vpc.default.id}"
availability_zone = "ap-northeast-1b"
cidr_block = "10.0.0.0/24"
tags {
Name = "${var.name}-1"
}
}
resource "aws_subnet" "default2" {
vpc_id = "${aws_vpc.default.id}"
availability_zone = "ap-northeast-1c"
cidr_block = "10.0.1.0/24"
tags {
Name = "${var.name}-2"
}
}
resource "aws_internet_gateway" "default" {
vpc_id = "${aws_vpc.default.id}"
tags {
Name = "${var.name}"
}
}
resource "aws_route_table" "default" {
vpc_id = "${aws_vpc.default.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.default.id}"
}
tags {
Name = "${var.name}"
}
}
resource "aws_route_table_association" "default1" {
subnet_id = "${aws_subnet.default1.id}"
route_table_id = "${aws_route_table.default.id}"
}
resource "aws_route_table_association" "default2" {
subnet_id = "${aws_subnet.default2.id}"
route_table_id = "${aws_route_table.default.id}"
}
resource "aws_main_route_table_association" "default" {
vpc_id = "${aws_vpc.default.id}"
route_table_id = "${aws_route_table.default.id}"
}
resource "aws_vpc_dhcp_options" "default" {
domain_name_servers = ["AmazonProvidedDNS"]
tags {
Name = "${var.name}"
}
}
resource "aws_vpc_dhcp_options_association" "default" {
vpc_id = "${aws_vpc.default.id}"
dhcp_options_id = "${aws_vpc_dhcp_options.default.id}"
}
resource "aws_security_group" "allow_all" {
vpc_id = "${aws_vpc.default.id}"
name = "allow_all"
description = "Allow all inbound traffic"
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags {
Name = "allow_all"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment