Page MenuHomePhabricator
Authored By
amckinley
Jun 30 2017, 3:53 PM
Size
2 KB
Referenced Files
None
Subscribers
None
# private subnet
resource "aws_subnet" "uber-private-1a" {
vpc_id = "${aws_vpc.private-cluster.id}"
cidr_block = "172.32.3.0/24"
map_public_ip_on_launch = false
availability_zone = "us-east-1a"
tags {
Name = "uber-private-us-east-1a"
customer = "Uber"
}
}
# test instance
resource "aws_instance" "terraform-test" {
ami = "ami-9a562df2"
instance_type = "t2.micro"
subnet_id = "${aws_subnet.uber-private-1a.id}"
key_name = "terraform-test"
vpc_security_group_ids = ["${aws_security_group.allow-all.id}"]
availability_zone = "us-east-1a"
timeouts {
create = "60m"
delete = "2h"
}
tags {
Name = "uber-phab"
}
}
# for each of the private ranges, create a "private" route table.
resource "aws_route_table" "uber-private-rt" {
vpc_id = "${aws_vpc.private-cluster.id}"
tags {
Name = "uber-private-route"
}
}
# routing table for private subnet
resource "aws_route" "private_nat_gateway_route" {
route_table_id = "${aws_route_table.uber-private-rt.id}"
destination_cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.us-east-1a-nat.id}"
}
# attach routing table to subnet
resource "aws_route_table_association" "uber-private-rt-assoc" {
subnet_id = "${aws_subnet.uber-private-1a.id}"
route_table_id = "${aws_route_table.uber-private-rt.id}"
}
# elb for ssh
resource "aws_elb" "ssh-elb" {
name = "terraform-example-elb"
subnets = ["${aws_subnet.public-us-east-1a.id}"]
security_groups = ["${aws_security_group.allow-all.id}"]
instances = ["${aws_instance.terraform-test.id}"]
# availability_zones = ["us-east-1a"]
listener {
instance_port = 22
instance_protocol = "tcp"
lb_port = 22
lb_protocol = "tcp"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 2
interval = 5
target = "TCP:22"
}
# The range for the idle timeout is from 1 to 3,600 seconds.
# idle_timeout = 60
}
# alb for http and notifications
resource "aws_alb" "uber-alb" {
name = "uber-alb"
internal = false
subnets = [
"${aws_subnet.public-us-east-1a.id}",
"${aws_subnet.public-us-east-1b.id}"]
security_groups = ["${aws_security_group.allow-all.id}"]
}
resource "aws_alb_target_group" "test" {
name = "uber-web-alb"
port = 80
protocol = "HTTP"
vpc_id = "${aws_vpc.private-cluster.id}"
}
resource "aws_alb_listener" "front_end" {
load_balancer_arn = "${aws_alb.uber-alb.id}"
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = "${aws_alb_target_group.test.id}"
type = "forward"
}
}
# attach the test instance to the target group
resource "aws_alb_target_group_attachment" "test" {
target_group_arn = "${aws_alb_target_group.test.arn}"
target_id = "${aws_instance.terraform-test.id}"
port = 80
}
# s3 route

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
701063
Default Alt Text
uber.tf (2 KB)

Event Timeline