Skip to content

Instantly share code, notes, and snippets.

@geekbass
Created March 28, 2019 23:32
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save geekbass/45eb978fb420ae0da13f00fdfa0cd1c5 to your computer and use it in GitHub Desktop.
Example Infra Module
# Find Public IP
data "http" "whatismyip" {
url = "http://whatismyip.akamai.com/"
}
# Begin Variables
variable "aws_ami" {
description = "AMI to use"
default = "ami-4bf3d731"
}
variable "cluster_name" {
description = "Name of your DC/OS Cluster"
default = "dcosansible"
}
variable "num_masters" {
description = "Number of Masters"
default = "3"
}
variable "num_private_agents" {
description = "Number of Private Agents"
default = "3"
}
variable "num_public_agents" {
description = "Number of Public Agents"
default = "1"
}
variable "ssh_public_key_file" {
description = "SSH Key Location"
default = "~/.ssh/id_rsa.pub"
}
# Begin Modules
module "dcos-infrastructure" {
source = "dcos-terraform/infrastructure/aws"
admin_ips = ["${data.http.whatismyip.body}/32"]
aws_ami = "${var.aws_ami}"
cluster_name = "${var.cluster_name}"
num_masters = "${var.num_masters}"
num_private_agents = "${var.num_private_agents}"
num_public_agents = "${var.num_public_agents}"
ssh_public_key_file = "${var.ssh_public_key_file}"
tags = {
owner = "wbassler"
expiration = "4h"
}
}
# Begin Outputs
output "bootstraps" {
description = "bootsrap IPs"
value = "${join("\n", flatten(list(module.dcos-infrastructure.bootstrap.public_ip)))}"
}
output "bootstrap_private_ip" {
description = "bootsrap IPs"
value = "${module.dcos-infrastructure.bootstrap.private_ip}"
}
output "masters" {
description = "masters IPs"
value = "${join("\n", flatten(list(module.dcos-infrastructure.masters.public_ips)))}"
}
output "masters_private_ips" {
description = "List of private IPs for Masters (for DCOS config)"
value = "${join("\n", flatten(list(module.dcos-infrastructure.masters.private_ips)))}"
}
output "private_agents" {
description = "Private Agents IPs"
value = "${join("\n", flatten(list(module.dcos-infrastructure.private_agents.public_ips)))}"
}
output "public_agents" {
description = "Public Agents IPs"
value = "${join("\n", flatten(list(module.dcos-infrastructure.public_agents.public_ips)))}"
}
output "cluster-address" {
value = "${module.dcos-infrastructure.elb.masters_dns_name}"
}
output "public-agents-loadbalancer" {
value = "${module.dcos-infrastructure.elb.public_agents_dns_name}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment