Skip to content

Instantly share code, notes, and snippets.

@gkze
Created January 18, 2015 23:09
Show Gist options
  • Save gkze/0a6f27bf9b306d9743ff to your computer and use it in GitHub Desktop.
Save gkze/0a6f27bf9b306d9743ff to your computer and use it in GitHub Desktop.
variable "aws_access_key" {}
variable "aws_secret_key" {}
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "us-east-1"
}
resource "aws_vpc" "terraform-testing" {
cidr_block = "10.0.0.0/16"
enable_dns_hostnames = true
tags {
Name = "tf-testing-vpc"
}
}
resource "aws_subnet" "tf-testing-e1a" {
availability_zone = "us-east-1a"
cidr_block = "10.0.1.0/24"
map_public_ip_on_launch = true
vpc_id = "${aws_vpc.terraform-testing.id}"
tags {
Name = "tf-subnet-e1a"
}
}
resource "aws_subnet" "tf-testing-e1d" {
availability_zone = "us-east-1d"
cidr_block = "10.0.2.0/24"
map_public_ip_on_launch = true
vpc_id = "${aws_vpc.terraform-testing.id}"
tags {
Name = "tf-subnet-e1d"
}
}
resource "aws_subnet" "tf-testing-e1e" {
availability_zone = "us-east-1e"
cidr_block = "10.0.3.0/24"
map_public_ip_on_launch = true
vpc_id = "${aws_vpc.terraform-testing.id}"
tags {
Name = "tf-subnet-e1e"
}
}
resource "aws_internet_gateway" "terraform-testing" {
vpc_id = "${aws_vpc.terraform-testing.id}"
}
resource "aws_route_table" "terraform-testing" {
vpc_id = "${aws_vpc.terraform-testing.id}"
route {
cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.terraform-testing.id}"
}
tags {
Name = "tf-testing-rtb"
}
}
resource "aws_route_table_association" "subnet-e1a" {
subnet_id = "${aws_subnet.tf-testing-e1a.id}"
route_table_id = "${aws_route_table.terraform-testing.id}"
}
resource "aws_route_table_association" "subnet-e1d" {
subnet_id = "${aws_subnet.tf-testing-e1d.id}"
route_table_id = "${aws_route_table.terraform-testing.id}"
}
resource "aws_route_table_association" "subnet-e1e" {
subnet_id = "${aws_subnet.tf-testing-e1e.id}"
route_table_id = "${aws_route_table.terraform-testing.id}"
}
resource "aws_security_group" "terraform-testing" {
name = "terraform-testing"
description = "Base allow all/all (managed by Terraform)"
vpc_id = "${aws_vpc.terraform-testing.id}"
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
self = true
}
ingress {
from_port = 0
to_port = 65535
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
self = true
}
ingress {
from_port = 0
to_port = 0
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
self = true
}
tags {
Name = "terraform-testing"
}
}
resource "aws_instance" "e1a" {
ami = "ami-4ae27e22"
availability_zone = "us-east-1a"
ebs_optimized = true
instance_type = "c4.2xlarge"
key_name = "cb_devops"
security_groups = ["${aws_security_group.terraform-testing.id}"]
subnet_id = "${aws_subnet.tf-testing-e1a.id}"
tags {
Name = "tf-testing-vpc-e1a"
}
}
resource "aws_instance" "e1d" {
ami = "ami-4ae27e22"
availability_zone = "us-east-1d"
ebs_optimized = true
instance_type = "c4.2xlarge"
key_name = "cb_devops"
security_groups = ["${aws_security_group.terraform-testing.id}"]
subnet_id = "${aws_subnet.tf-testing-e1d.id}"
tags {
Name = "tf-testing-vpc-e1d"
}
}
resource "aws_instance" "e1e" {
ami = "ami-4ae27e22"
availability_zone = "us-east-1e"
ebs_optimized = true
instance_type = "c4.2xlarge"
key_name = "cb_devops"
security_groups = ["${aws_security_group.terraform-testing.id}"]
subnet_id = "${aws_subnet.tf-testing-e1e.id}"
tags {
Name = "tf-testing-vpc-e1e"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment