Created
January 16, 2015 21:01
-
-
Save bhameyie/61889b8fe4b219e6cdce to your computer and use it in GitHub Desktop.
Sample terraform vms
This file contains hidden or 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
variable "memory" {} | |
variable "environment" {} | |
variable "version" {} | |
variable "region" {} | |
variable "aws_secretkey" {} | |
variable "aws_accesskey" {} | |
variable "docker_email" {} | |
variable "docker_user" {} | |
variable "docker_pass" {} | |
variable "mongo_uri" {} | |
variable "neo4j_uri" {} | |
variable "do_token" {} | |
variable "pub_key" {} | |
variable "pvt_key" {} | |
variable "ssh_fingerprint" {} | |
variable "rabbit_uri" {} | |
provider "aws" { | |
access_key = "${var.aws_accesskey}" | |
secret_key = "${var.aws_secretkey}" | |
region = "${var.region}" | |
} | |
resource "aws_instance" "user-microservice" { | |
ami = "ami-705d3d18" | |
instance_type = "${var.memory}" | |
key_name = "deployment" | |
security_groups = ["http-traffic"] | |
tags { | |
Module = "user-microservice" | |
Environment = "${var.environment}" | |
Version = "${var.version}" | |
} | |
connection { | |
user = "core" | |
type = "ssh" | |
key_file = "${var.pvt_key}" | |
timeout = "5m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"docker login --email=${var.docker_email} --password=${var.docker_pass} --username=${var.docker_user}", | |
"docker run -d -e 'PORT=80' -e 'RABBIT_PROD_SVR=${var.rabbit_uri}' -e 'MONGO_PROD_URI=${var.mongo_uri}' -e 'NEO_PROD_SVR=${var.neo4j_uri}' -p 80:80 --name=user-microservice -t thor/user-microservice:${var.version}" | |
] | |
} | |
} | |
resource "aws_instance" "other-microservice" { | |
ami = "ami-705d3d18" | |
instance_type = "${var.memory}" | |
key_name = "deployment" | |
security_groups = ["http-traffic"] | |
tags { | |
Module = "other-microservice" | |
Environment = "${var.environment}" | |
Version = "${var.version}" | |
} | |
connection { | |
user = "core" | |
type = "ssh" | |
key_file = "${var.pvt_key}" | |
timeout = "5m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"docker login --email=${var.docker_email} --password=${var.docker_pass} --username=${var.docker_user}", | |
"docker run -d -e 'PORT=80' -e 'RABBIT_PROD_SVR=${var.rabbit_uri}' -e 'MONGO_PROD_URI=${var.mongo_uri}' -e 'NEO_PROD_SVR=${var.neo4j_uri}' -p 80:80 --name=other-microservice -t thor/other-microservice:${var.version}" | |
] | |
} | |
} | |
output "other-dns" { | |
value = "${aws_instance.other-microservice.public_dns}" | |
} | |
output "user-dns" { | |
value = "${aws_instance.user-microservice.public_dns}" | |
} | |
output "other-az" { | |
value = "${aws_instance.other-microservice.availability_zone}" | |
} | |
output "user-az" { | |
value = "${aws_instance.user-microservice.availability_zone}" | |
} | |
output "other-id" { | |
value = "${aws_instance.other-microservice.id}" | |
} | |
output "user-id" { | |
value = "${aws_instance.user-microservice.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment