Created
January 16, 2015 21:10
-
-
Save bhameyie/22688d3d6f1c4d2333bd to your computer and use it in GitHub Desktop.
Sample vms usage
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
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