github.com/ewbankkit/terraform@v0.7.7/examples/clc/main.tf (about) 1 # -------------------- 2 # Credentials 3 provider "clc" { 4 username = "${var.clc_username}" 5 password = "${var.clc_password}" 6 account = "${var.clc_account}" 7 } 8 9 # -------------------- 10 # Provision/Resolve a server group 11 resource "clc_group" "frontends" { 12 location_id = "CA1" 13 name = "frontends" 14 parent = "Default Group" 15 } 16 17 # -------------------- 18 # Provision a server 19 resource "clc_server" "node" { 20 name_template = "trusty" 21 source_server_id = "UBUNTU-14-64-TEMPLATE" 22 group_id = "${clc_group.frontends.id}" 23 cpu = 2 24 memory_mb = 2048 25 password = "Green123$" 26 27 additional_disks { 28 path = "/var" 29 size_gb = 100 30 type = "partitioned" 31 } 32 33 additional_disks { 34 size_gb = 10 35 type = "raw" 36 } 37 } 38 39 # -------------------- 40 # Provision a public ip 41 resource "clc_public_ip" "backdoor" { 42 server_id = "${clc_server.node.0.id}" 43 internal_ip_address = "${clc_server.node.0.private_ip_address}" 44 45 ports { 46 protocol = "ICMP" 47 port = -1 48 } 49 50 ports { 51 protocol = "TCP" 52 port = 22 53 } 54 55 source_restrictions { 56 cidr = "173.60.0.0/16" 57 } 58 59 # ssh in and start a simple http server on :8080 60 provisioner "remote-exec" { 61 inline = [ 62 "cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &", 63 ] 64 65 connection { 66 host = "${clc_public_ip.backdoor.id}" 67 user = "root" 68 password = "${clc_server.node.password}" 69 } 70 } 71 } 72 73 # -------------------- 74 # Provision a load balancer 75 resource "clc_load_balancer" "frontdoor" { 76 data_center = "${clc_group.frontends.location_id}" 77 name = "frontdoor" 78 description = "frontdoor" 79 status = "enabled" 80 } 81 82 # -------------------- 83 # Provision a load balancer pool 84 resource "clc_load_balancer_pool" "pool" { 85 data_center = "${clc_group.frontends.location_id}" 86 load_balancer = "${clc_load_balancer.frontdoor.id}" 87 method = "roundRobin" 88 persistence = "standard" 89 port = 80 90 91 nodes { 92 status = "enabled" 93 ipAddress = "${clc_server.node.private_ip_address}" 94 privatePort = 8000 95 } 96 }