Skip to content

Three updates to enable working project by default #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: edit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion terraform/README.md

This file was deleted.

12 changes: 10 additions & 2 deletions terraform/app-servers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ resource "aws_instance" "app" {
source_dest_check = false
user_data = "${file(\"cloud-config/app.yml\")}"
tags = {
Name = "airpair-example-app-${count.index}"
Name = "meetup-example-app-${count.index}"
}
}

/* Load balancer */
resource "aws_elb" "app" {
name = "airpair-example-elb"
name = "meetup-example-elb"
subnets = ["${aws_subnet.public.id}"]
security_groups = ["${aws_security_group.default.id}", "${aws_security_group.web.id}"]
listener {
Expand All @@ -24,5 +24,13 @@ resource "aws_elb" "app" {
lb_port = 80
lb_protocol = "http"
}
health_check {
healthy_threshold = 2
unhealthy_threshold = 2
timeout = 5
target = "HTTP:80/"
interval = 15
}

instances = ["${aws_instance.app.*.id}"]
}
Binary file removed terraform/assets/header.png
Binary file not shown.
2 changes: 1 addition & 1 deletion terraform/aws-vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ resource "aws_vpc" "default" {
cidr_block = "${var.vpc_cidr}"
enable_dns_hostnames = true
tags {
Name = "airpair-example"
Name = "meetup-example"
}
}
2 changes: 1 addition & 1 deletion terraform/bin/ovpn-client-config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ssh -t -i ssh/insecure-deployer "ubuntu@$(terraform output nat.ip)" sudo docker run --volumes-from ovpn-data --rm gosuri/openvpn ovpn_getclient "${1}" > "${1}-airpair-example.ovpn"
ssh -t -i ssh/insecure-deployer "ubuntu@$(terraform output nat.ip)" sudo docker run --volumes-from ovpn-data --rm gosuri/openvpn ovpn_getclient "${1}" > "${1}-meetup-example.ovpn"
2 changes: 1 addition & 1 deletion terraform/bin/ovpn-init
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ssh -t -i ssh/insecure-deployer ubuntu@54.153.64.109 sudo docker run --volumes-from ovpn-data --rm -it gosuri/openvpn ovpn_initpki
ssh -t -i ssh/insecure-deployer "ubuntu@$(terraform output nat.ip)" sudo docker run --volumes-from ovpn-data --rm -it gosuri/openvpn ovpn_initpki
2 changes: 1 addition & 1 deletion terraform/cloud-config/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ runcmd:
# Install docker
- curl -sSL https://get.docker.com/ubuntu/ | sudo sh
# Run nginx
- docker run -d -p 80:80 dockerfile/nginx
- docker run -d -p 80:80 nginx
2 changes: 1 addition & 1 deletion terraform/key-pairs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_key_pair" "deployer" {
key_name = "deployer-airpair-example"
key_name = "deployer-meetup-example"
public_key = "${file(\"ssh/insecure-deployer.pub\")}"
}

2 changes: 1 addition & 1 deletion terraform/nat-server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_instance" "nat" {
provisioner "remote-exec" {
inline = [
"sudo iptables -t nat -A POSTROUTING -j MASQUERADE",
"echo 1 > /proc/sys/net/ipv4/conf/all/forwarding",
"echo 1 | sudo tee /proc/sys/net/ipv4/conf/all/forwarding",
/* Install docker */
"curl -sSL https://get.docker.com/ubuntu/ | sudo sh",
/* Initialize open vpn data container */
Expand Down
4 changes: 4 additions & 0 deletions terraform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ output "app.1.ip" {
value = "${aws_instance.app.1.private_ip}"
}

/*output "appservers" {
value = "${join(",", aws_instance.app.*.private_ip)}"
}*/

output "nat.ip" {
value = "${aws_instance.nat.public_ip}"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/private-subnet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
resource "aws_subnet" "private" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "${var.private_subnet_cidr}"
availability_zone = "us-west-1a"
availability_zone = "us-west-1b"
map_public_ip_on_launch = false
depends_on = ["aws_instance.nat"]
tags {
Expand Down
2 changes: 1 addition & 1 deletion terraform/public-subnet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ resource "aws_internet_gateway" "default" {
resource "aws_subnet" "public" {
vpc_id = "${aws_vpc.default.id}"
cidr_block = "${var.public_subnet_cidr}"
availability_zone = "us-west-1a"
availability_zone = "us-west-1b"
map_public_ip_on_launch = true
depends_on = ["aws_internet_gateway.default"]
tags {
Expand Down
34 changes: 24 additions & 10 deletions terraform/security-groups.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Default security group */
resource "aws_security_group" "default" {
name = "default-airpair-example"
name = "default-meetup-example"
description = "Default security group that allows inbound and outbound traffic from all instances in the VPC"
vpc_id = "${aws_vpc.default.id}"

Expand All @@ -10,16 +10,23 @@ resource "aws_security_group" "default" {
protocol = "-1"
self = true
}

tags {
Name = "airpair-example-default-vpc"

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags {
Name = "meetup-example-default-vpc"
}
}


/* Security group for the nat server */
resource "aws_security_group" "nat" {
name = "nat-airpair-example"
name = "nat-meetup-example"
description = "Security group for nat instances that allows SSH and VPN traffic from internet"
vpc_id = "${aws_vpc.default.id}"

Expand All @@ -36,15 +43,22 @@ resource "aws_security_group" "nat" {
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}

tags {
Name = "nat-airpair-example"

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

tags {
Name = "nat-meetup-example"
}
}

/* Security group for the web */
resource "aws_security_group" "web" {
name = "web-airpair-example"
name = "web-meetup-example"
description = "Security group for web that allows web traffic from internet"
vpc_id = "${aws_vpc.default.id}"

Expand All @@ -63,6 +77,6 @@ resource "aws_security_group" "web" {
}

tags {
Name = "web-airpair-example"
Name = "web-meetup-example"
}
}