-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial modularisation of aws-public
- Loading branch information
Showing
15 changed files
with
168 additions
and
132 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
variable "elb_name" { default = "apollo-elb" } | ||
variable "backend_port" { default = "80"} | ||
variable "backend_protocol" { default = "http" } | ||
variable "health_check_target" { default = "HTTP:8888/health" } | ||
variable "instances" {} | ||
variable "subnets" {} | ||
variable "security_groups" {} | ||
|
||
resource "aws_elb" "elb" { | ||
name = "${var.elb_name}" | ||
cross_zone_load_balancing = true | ||
subnets = ["${split(\",\", var.subnets)}"] | ||
security_groups = ["${split(\",\",var.security_groups)}"] | ||
instances = ["${split(\",\", var.instances)}"] | ||
listener { | ||
instance_port = "${var.backend_port}" | ||
instance_protocol = "${var.backend_protocol}" | ||
lb_port = 80 | ||
lb_protocol = "http" | ||
} | ||
# Traefik health check | ||
health_check { | ||
healthy_threshold = 2 | ||
unhealthy_threshold = 2 | ||
timeout = 3 | ||
target = "${var.health_check_target}" | ||
interval = 30 | ||
} | ||
tags { | ||
Name = "${var.elb_name}" | ||
} | ||
} | ||
resource "aws_proxy_protocol_policy" "http" { | ||
load_balancer = "${aws_elb.elb.name}" | ||
instance_ports = ["80"] | ||
} | ||
# outputs | ||
output "elb_id" { value = "${aws_elb.elb.id}" } | ||
output "elb_name" { value = "${aws_elb.elb.name}" } | ||
output "elb_dns_name" { value = "${aws_elb.elb.dns_name}" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
https://discovery.etcd.io/365f729dcd00529b8a181c72a4c66f6a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# input variables | ||
variable "short_name" { default = "apollo" } | ||
variable "public_key_filename" { default = "~/.ssh/id_rsa_aws.pub" } | ||
|
||
# SSH keypair for the instances | ||
resource "aws_key_pair" "default" { | ||
key_name = "${var.short_name}" | ||
public_key = "${file(var.public_key_filename)}" | ||
} | ||
|
||
# output variables | ||
output "keypair_name" { | ||
value = "${aws_key_pair.default.key_name}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
provider "aws" { | ||
access_key = "${var.access_key}" | ||
secret_key = "${var.secret_key}" | ||
region = "${var.region}" | ||
} | ||
|
||
resource "aws_vpc" "default" { | ||
cidr_block = "${var.vpc_cidr_block}" | ||
enable_dns_support = true | ||
enable_dns_hostnames = true | ||
lifecycle { | ||
create_before_destroy = true | ||
} | ||
} | ||
|
||
# ssh keypair for instances | ||
module "aws-keypair" { | ||
source = "./keypair" | ||
|
||
public_key_filename = "${var.public_key_file}" | ||
} | ||
|
||
# internet gateway | ||
module "igw" { | ||
source = "github.com/terraform-community-modules/tf_aws_igw" | ||
|
||
name = "public" | ||
vpc_id = "${aws_vpc.default.id}" | ||
} | ||
|
||
# public subnets | ||
module "public_subnet" { | ||
source = "github.com/terraform-community-modules/tf_aws_public_subnet" | ||
|
||
name = "public" | ||
cidrs = "10.0.1.0/24,10.0.2.0/24,10.0.3.0/24" | ||
azs = "${var.availability_zones}" | ||
vpc_id = "${aws_vpc.default.id}" | ||
igw_id = "${module.igw.igw_id}" | ||
} | ||
|
||
# security group to allow all traffic in and out of the instances | ||
module "sg-default" { | ||
source = "./sg-all-traffic" | ||
|
||
vpc_id = "${aws_vpc.default.id}" | ||
} | ||
|
||
module "elb" { | ||
source = "./elb" | ||
|
||
security_groups = "${module.sg-default.security_group_id}" | ||
instances = "${join(\",\", aws_instance.mesos-slave.*.id)}" | ||
subnets = "${module.public_subnet.subnet_ids}" | ||
} | ||
# Generate an etcd URL for the cluster | ||
resource "template_file" "etcd_discovery_url" { | ||
template = "/dev/null" | ||
provisioner "local-exec" { | ||
command = "curl https://discovery.etcd.io/new?size=${var.masters + var.slaves} > ${var.etcd_discovery_url_file}" | ||
} | ||
# This will regenerate the discovery URL if the cluster size changes | ||
vars { | ||
size = "${var.masters + var.slaves}" | ||
} | ||
} | ||
# outputs | ||
output "master.1.ip" { | ||
value = "${aws_instance.mesos-master.0.public_ip}" | ||
} | ||
output "master_ips" { | ||
value = "${join(",", aws_instance.mesos-master.*.public_ip)}" | ||
} | ||
output "slave_ips" { | ||
value = "${join(",", aws_instance.mesos-slave.*.public_ip)}" | ||
} | ||
output "elb.hostname" { | ||
value = "${module.elb.elb_dns_name}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
variable "access_key" {} | ||
variable "secret_key" {} | ||
variable "key_name" { default = "deployer"} | ||
variable "key_file" {} | ||
variable "public_key_file" { default = "~/.ssh/id_rsa_aws.pub" } | ||
variable "region" { default = "eu-west-1" } | ||
variable "availability_zones" { default = "" } # zones list separated by , | ||
variable "availability_zones" { default = "eu-west-1a,eu-west-1b,eu-west-1c" } | ||
variable "coreos_channel" { default = "stable" } | ||
variable "etcd_discovery_url_file" { default = "etcd_discovery_url.txt" } | ||
variable "masters" { default = "3" } | ||
variable "master_instance_type" { default = "m3.medium" } | ||
variable "slaves" { default = "1" } | ||
variable "slave_instance_type" { default = "m3.medium" } | ||
variable "elb_name" { default = "apollo-elb" } | ||
variable "vpc_cidr_block" { default = "10.0.0.0/16" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters