Skip to content

Commit

Permalink
Adding Cloudflare domain association
Browse files Browse the repository at this point in the history
  • Loading branch information
yamilurbina committed Dec 14, 2018
1 parent 0ba3e0d commit 71f904d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/hashiapp/Hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public static void main(final String[] args) {
port(4567);
}

model.put("app_version", "v2.0");

get("/", (req, res) -> new ModelAndView(model, "home.vm"), new VelocityTemplateEngine());
get("/version", (req, res) -> "v2.0");
get("/health", (req, res) -> "OK");
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/home.vm
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
<link rel="stylesheet" href="/css/bulma.min.css">
</head>
<body>
<section class="hero is-medium is-primary is-bold">
<section class="hero is-primary is-primary is-bold">
<div class="hero-body">
<div class="content has-text-centered is-large">
<h1 class="title is-1 is-spaced">La Paz Cloud</h1>
<h1 class="title is-1 is-spaced">La Paz Cloud $app_version</h1>
<p class="subtitle">Aplicación en Spark</p>
<a href="https://github.com/lapazcloud/hashiapp" target="_blank" class="button is-medium is-link">Ver código fuente</a>
<p><small>$server_id</small></p>
</div>
</div>
</section>
Expand All @@ -34,7 +35,6 @@
<footer class="footer">
<div class="content has-text-centered has-text-grey-light">
<p>Copyright &copy; 2018 La Paz Cloud</p>
<small>$server_id</small>
</div>
</footer>
</body>
Expand Down
33 changes: 33 additions & 0 deletions terraform/servers.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
provider "digitalocean" {}
provider "cloudflare" {}

provider "aws" {
region = "us-east-1"
Expand Down Expand Up @@ -62,6 +63,38 @@ resource "digitalocean_droplet" "worker" {
user_data = "${data.template_file.worker.rendered}"
}

resource "digitalocean_loadbalancer" "hashilb" {
name = "hashilb"
region = "nyc3"

forwarding_rule {
entry_port = 80
entry_protocol = "http"

target_port = 9999
target_protocol = "http"
}

healthcheck {
port = 9999
protocol = "tcp"
}

droplet_ids = ["${digitalocean_droplet.worker.*.id}"]
}

resource "cloudflare_record" "domain" {
domain = "lapazcloud.com"
name = "@"
value = "${digitalocean_loadbalancer.hashilb.ip}"
type = "A"
ttl = 1
}

output "load-balancer" {
value = "http://${digitalocean_loadbalancer.hashilb.ip}/"
}

output "db-address" {
value = "${aws_db_instance.db.endpoint}"
}
Expand Down

0 comments on commit 71f904d

Please sign in to comment.