Skip to content

Commit

Permalink
Create route53 record and use create certificate using let's encrypt
Browse files Browse the repository at this point in the history
  • Loading branch information
florello-tbox committed Aug 27, 2018
1 parent 3e09765 commit 05b71e4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aws/files/userdata_server
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for image in $curlimage $jqimage "rancher/rancher:${rancher_version}"; do
done
done

docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /root/rancher:/var/lib/rancher rancher/rancher:${rancher_version}
docker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /root/rancher:/var/lib/rancher rancher/rancher:${rancher_version} --acme-domain ${rancher_domain_name}

while true; do
docker run --rm --net=host $curlimage -sLk https://127.0.0.1/ping && break
Expand Down
21 changes: 20 additions & 1 deletion aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ variable "aws_secret_key" {
description = "Amazon AWS Secret Key"
}

variable "aws_route53_zone_id" {
default = "xxx"
description = "Amazon Route 53 primary zone id"
}

variable "prefix" {
default = "yourname"
description = "Cluster Prefix - All resources created by Terraform have this prefix prepended to them"
}

variable "rancher_domain_name" {
default = ""
description = "ACME domain name for rancher server"
}

variable "rancher_version" {
default = "latest"
description = "Rancher Server Version"
Expand Down Expand Up @@ -137,6 +147,14 @@ resource "aws_instance" "rancherserver" {
}
}

resource "aws_route53_record" "www" {
zone_id = "${var.aws_route53_zone_id}"
name = "${var.rancher_domain_name}"
type = "A"
ttl = "60"
records = ["${aws_instance.rancherserver.public_ip}"]
}

data "template_cloudinit_config" "rancheragent-all-cloudinit" {
count = "${var.count_agent_all_nodes}"

Expand Down Expand Up @@ -252,6 +270,7 @@ data "template_file" "userdata_server" {
admin_password = "${var.admin_password}"
cluster_name = "${var.cluster_name}"
docker_version_server = "${var.docker_version_server}"
rancher_domain_name = "${var.rancher_domain_name}"
rancher_version = "${var.rancher_version}"
}
}
Expand All @@ -270,5 +289,5 @@ data "template_file" "userdata_agent" {
}

output "rancher-url" {
value = ["https://${aws_instance.rancherserver.public_ip}"]
value = ["https://${aws_instance.rancherserver.public_ip} or https://${var.rancher_domain_name}"]
}
4 changes: 4 additions & 0 deletions aws/terraform.tfvars.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
aws_access_key = "your-aws-access-key"
# Amazon AWS Secret Key
aws_secret_key = "your-aws-secret-key"
# Amazon Route 53 zone id
aws_route53_zone_id = "your-route53-zone-id"
# Amazon AWS Key Pair Name
ssh_key_name = "your-aws-key-pair-name"
# Region where resources should be created
Expand All @@ -12,6 +14,8 @@ cluster_name = "tboxapps"
prefix = "tbox"
# Admin password to access Rancher
admin_password = "admin"
# Rancher domain name
rancher_domain_name = "rancher.tboxapps.uk"
# rancher/rancher image tag to use
rancher_version = "latest"
# Count of agent nodes with role all
Expand Down

0 comments on commit 05b71e4

Please sign in to comment.