Skip to content

Instantly share code, notes, and snippets.

@aibou
Created December 11, 2015 02:12
Show Gist options
  • Save aibou/7a11910963c5c9724703 to your computer and use it in GitHub Desktop.
Save aibou/7a11910963c5c9724703 to your computer and use it in GitHub Desktop.
terraformでVPC作るやつ
resource "aws_vpc" "loadtest" {
cidr_block = "10.200.0.0/16"
enable_dns_support = true
enable_dns_hostnames = true
tags {
Name = "load-test"
}
}
resource "aws_subnet" "public-loadtest-a" {
vpc_id = "${aws_vpc.loadtest.id}"
cidr_block = "10.200.0.0/20"
availability_zone = "${var.aws_region}a"
tags {
Name = "public-loadtest-a"
}
}
resource "aws_subnet" "public-loadtest-c" {
vpc_id = "${aws_vpc.loadtest.id}"
cidr_block = "10.200.16.0/20"
availability_zone = "${var.aws_region}c"
tags {
Name = "public-loadtest-c"
}
}
resource "aws_internet_gateway" "loadtest-igw" {
vpc_id = "${aws_vpc.loadtest.id}"
tags {
Name = "loadtest-igw"
}
}
resource "aws_route_table" "loadtest-a-rtb" {
vpc_id = "${aws_vpc.loadtest.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.loadtest-igw.id}"
}
tags {
Name = "loadtest-a-rtb"
}
}
resource "aws_route_table" "loadtest-c-rtb" {
vpc_id = "${aws_vpc.loadtest.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.loadtest-igw.id}"
}
tags {
Name = "loadtest-c-rtb"
}
}
resource "aws_route_table_association" "a" {
subnet_id = "${aws_subnet.public-loadtest-a.id}"
route_table_id = "${aws_route_table.loadtest-a-rtb.id}"
}
resource "aws_route_table_association" "c" {
subnet_id = "${aws_subnet.public-loadtest-c.id}"
route_table_id = "${aws_route_table.loadtest-c-rtb.id}"
}
resource "aws_security_group" "elb" {
name = ""
vpc_id = "${aws_vpc.loadtest.id}"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
@aibou
Copy link
Author

aibou commented Dec 11, 2015

route table、local足りない気がする

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment