Skip to content

Instantly share code, notes, and snippets.

@bhameyie
Created January 16, 2015 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhameyie/22688d3d6f1c4d2333bd to your computer and use it in GitHub Desktop.
Save bhameyie/22688d3d6f1c4d2333bd to your computer and use it in GitHub Desktop.
Sample vms usage
provider "aws" {
access_key = "${var.aws_accesskey}"
secret_key = "${var.aws_secretkey}"
region = "us-east-1"
}
module "appsvr1" {
source = "../app_servers"
region = "us-east-1"
memory = "t2.small"
environment = "prod"
version = "${var.version}"
aws_accesskey = "${var.aws_accesskey}"
aws_secretkey = "${var.aws_secretkey}"
ssh_fingerprint = "${var.ssh_fingerprint}"
docker_email = "${var.docker_email}"
docker_user = "${var.docker_user}"
docker_pass = "${var.docker_pass}"
mongo_uri = "${var.mongo_uri}"
neo4j_uri = "${var.neo4j_uri}"
pub_key = "${var.pub_key}"
pvt_key = "${var.pvt_key}"
do_token = "${var.do_token}"
rabbit_uri = "${var.rabbit_uri}"
}
module "appsvr2" {
source = "../app_servers"
region = "us-east-1"
memory = "t2.small"
environment = "prod"
version = "${var.version}"
aws_accesskey = "${var.aws_accesskey}"
aws_secretkey = "${var.aws_secretkey}"
ssh_fingerprint = "${var.ssh_fingerprint}"
docker_email = "${var.docker_email}"
docker_user = "${var.docker_user}"
docker_pass = "${var.docker_pass}"
mongo_uri = "${var.mongo_uri}"
neo4j_uri = "${var.neo4j_uri}"
pub_key = "${var.pub_key}"
pvt_key = "${var.pvt_key}"
do_token = "${var.do_token}"
rabbit_uri = "${var.rabbit_uri}"
}
resource "aws_elb" "user" {
name = "user-prod-${var.version}"
availability_zones = ["${module.appsvr1.user-az}","${module.appsvr2.user-az}"]
listener {
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
# The instance is registered automatically
instances = ["${module.appsvr1.user-id}","${module.appsvr2.user-id}"]
}
resource "aws_elb" "other" {
name = "other-prod-${var.version}"
availability_zones = ["${module.appsvr1.other-az}","${module.appsvr2.other-az}"]
listener {
instance_port = 80
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
# The instance is registered automatically
instances = ["${module.appsvr1.other-id}","${module.appsvr2.other-id}"]
}
resource "aws_route53_record" "user" {
zone_id = "YOURS"
name = "userservice.yours.com"
type = "CNAME"
ttl = "300"
records = ["${aws_elb.user.dns_name}"]
}
resource "aws_route53_record" "other" {
zone_id = "YOURS"
name = "otherservice.yours.com"
type = "CNAME"
ttl = "300"
records = ["${aws_elb.other.dns_name}"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment