From c6beaa7ce8e2f9420052745405d0c574691c8e52 Mon Sep 17 00:00:00 2001 From: Valentin Pichard Date: Thu, 22 Sep 2016 11:49:09 +0000 Subject: [PATCH] Fmt all the config files Signed-off-by: Valentin Pichard --- examples/aws-asg/main.tf | 64 +++--- examples/aws-asg/outputs.tf | 3 + examples/aws-asg/variables.tf | 13 +- .../aws-cloudwatch-events/kinesis/main.tf | 16 +- .../kinesis/variables.tf | 10 +- examples/aws-cloudwatch-events/sns/main.tf | 5 +- .../aws-cloudwatch-events/sns/variables.tf | 8 +- examples/aws-count/main.tf | 9 +- examples/aws-count/variables.tf | 2 +- examples/aws-ecs-alb/main.tf | 148 ++++++------ examples/aws-ecs-alb/variables.tf | 12 +- examples/aws-eip/main.tf | 24 +- examples/aws-eip/outputs.tf | 1 + examples/aws-eip/variables.tf | 3 +- examples/aws-elb/main.tf | 72 +++--- examples/aws-elb/variables.tf | 3 +- examples/aws-rds/main.tf | 24 +- examples/aws-rds/outputs.tf | 3 +- examples/aws-rds/sg-variables.tf | 5 +- examples/aws-rds/sg.tf | 16 +- examples/aws-rds/subnet-variables.tf | 9 +- examples/aws-rds/subnets.tf | 8 +- examples/aws-rds/variables.tf | 15 +- examples/aws-s3-cross-account-access/main.tf | 11 +- .../aws-s3-cross-account-access/variables.tf | 3 + examples/aws-two-tier/main.tf | 4 +- examples/aws-two-tier/variables.tf | 2 +- examples/clc/main.tf | 98 ++++---- examples/clc/outputs.tf | 2 +- examples/clc/variables.tf | 3 +- examples/consul/main.tf | 21 +- examples/consul/variables.tf | 10 +- examples/cross-provider/main.tf | 4 +- examples/digitalocean/main.tf | 63 +++--- examples/digitalocean/outputs.tf | 4 +- examples/digitalocean/variable.tf | 55 ++--- examples/gce-vpn/variables.tf | 6 +- examples/gce-vpn/vpn.tf | 212 +++++++++--------- examples/google-two-tier/main.tf | 53 ++--- examples/google-two-tier/variables.tf | 10 +- examples/openstack-with-networking/main.tf | 66 +++--- examples/openstack-with-networking/outputs.tf | 2 +- .../openstack-with-networking/variables.tf | 13 +- 43 files changed, 582 insertions(+), 533 deletions(-) diff --git a/examples/aws-asg/main.tf b/examples/aws-asg/main.tf index 8f172352d..b70e89584 100644 --- a/examples/aws-asg/main.tf +++ b/examples/aws-asg/main.tf @@ -8,77 +8,79 @@ resource "aws_elb" "web-elb" { # The same availability zone as our instances availability_zones = ["${split(",", var.availability_zones)}"] + listener { - instance_port = 80 + instance_port = 80 instance_protocol = "http" - lb_port = 80 - lb_protocol = "http" + lb_port = 80 + lb_protocol = "http" } health_check { - healthy_threshold = 2 + healthy_threshold = 2 unhealthy_threshold = 2 - timeout = 3 - target = "HTTP:80/" - interval = 30 + timeout = 3 + target = "HTTP:80/" + interval = 30 } - } resource "aws_autoscaling_group" "web-asg" { - availability_zones = ["${split(",", var.availability_zones)}"] - name = "terraform-example-asg" - max_size = "${var.asg_max}" - min_size = "${var.asg_min}" - desired_capacity = "${var.asg_desired}" - force_delete = true + availability_zones = ["${split(",", var.availability_zones)}"] + name = "terraform-example-asg" + max_size = "${var.asg_max}" + min_size = "${var.asg_min}" + desired_capacity = "${var.asg_desired}" + force_delete = true launch_configuration = "${aws_launch_configuration.web-lc.name}" - load_balancers = ["${aws_elb.web-elb.name}"] + load_balancers = ["${aws_elb.web-elb.name}"] + #vpc_zone_identifier = ["${split(",", var.availability_zones)}"] tag { - key = "Name" - value = "web-asg" + key = "Name" + value = "web-asg" propagate_at_launch = "true" } } resource "aws_launch_configuration" "web-lc" { - name = "terraform-example-lc" - image_id = "${lookup(var.aws_amis, var.aws_region)}" + name = "terraform-example-lc" + image_id = "${lookup(var.aws_amis, var.aws_region)}" instance_type = "${var.instance_type}" + # Security group security_groups = ["${aws_security_group.default.id}"] - user_data = "${file("userdata.sh")}" - key_name = "${var.key_name}" + user_data = "${file("userdata.sh")}" + key_name = "${var.key_name}" } # Our default security group to access # the instances over SSH and HTTP resource "aws_security_group" "default" { - name = "terraform_example_sg" + name = "terraform_example_sg" description = "Used in the terraform" # SSH access from anywhere ingress { - from_port = 22 - to_port = 22 - protocol = "tcp" + from_port = 22 + to_port = 22 + protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } # HTTP access from anywhere ingress { - from_port = 80 - to_port = 80 - protocol = "tcp" + from_port = 80 + to_port = 80 + protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } # outbound internet access egress { - from_port = 0 - to_port = 0 - protocol = "-1" + from_port = 0 + to_port = 0 + protocol = "-1" cidr_blocks = ["0.0.0.0/0"] } } diff --git a/examples/aws-asg/outputs.tf b/examples/aws-asg/outputs.tf index a85793efb..faa5864c5 100644 --- a/examples/aws-asg/outputs.tf +++ b/examples/aws-asg/outputs.tf @@ -1,12 +1,15 @@ output "security_group" { value = "${aws_security_group.default.id}" } + output "launch_configuration" { value = "${aws_launch_configuration.web-lc.id}" } + output "asg_name" { value = "${aws_autoscaling_group.web-asg.id}" } + output "elb_name" { value = "${aws_elb.web-elb.dns_name}" } diff --git a/examples/aws-asg/variables.tf b/examples/aws-asg/variables.tf index 0171e4704..d45c10d25 100644 --- a/examples/aws-asg/variables.tf +++ b/examples/aws-asg/variables.tf @@ -1,6 +1,6 @@ variable "aws_region" { description = "The AWS region to create things in." - default = "us-east-1" + default = "us-east-1" } # ubuntu-trusty-14.04 (x64) @@ -12,7 +12,7 @@ variable "aws_amis" { } variable "availability_zones" { - default = "us-east-1b,us-east-1c,us-east-1d,us-east-1e" + default = "us-east-1b,us-east-1c,us-east-1d,us-east-1e" description = "List of availability zones, use AWS CLI to find your " } @@ -21,22 +21,21 @@ variable "key_name" { } variable "instance_type" { - default = "t2.micro" + default = "t2.micro" description = "AWS instance type" } variable "asg_min" { description = "Min numbers of servers in ASG" - default = "1" + default = "1" } variable "asg_max" { description = "Max numbers of servers in ASG" - default = "2" + default = "2" } variable "asg_desired" { description = "Desired numbers of servers in ASG" - default = "1" + default = "1" } - diff --git a/examples/aws-cloudwatch-events/kinesis/main.tf b/examples/aws-cloudwatch-events/kinesis/main.tf index 0e7a22052..db8555020 100644 --- a/examples/aws-cloudwatch-events/kinesis/main.tf +++ b/examples/aws-cloudwatch-events/kinesis/main.tf @@ -4,6 +4,7 @@ provider "aws" { resource "aws_cloudwatch_event_rule" "foo" { name = "${var.rule_name}" + event_pattern = < /dev/null 2>&1 &" + "cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &", ] + connection { - host = "${clc_public_ip.backdoor.id}" - user = "root" + host = "${clc_public_ip.backdoor.id}" + user = "root" password = "${clc_server.node.password}" } } - } - # -------------------- # Provision a load balancer resource "clc_load_balancer" "frontdoor" { data_center = "${clc_group.frontends.location_id}" - name = "frontdoor" + name = "frontdoor" description = "frontdoor" - status = "enabled" + status = "enabled" } # -------------------- # Provision a load balancer pool resource "clc_load_balancer_pool" "pool" { - data_center = "${clc_group.frontends.location_id}" + data_center = "${clc_group.frontends.location_id}" load_balancer = "${clc_load_balancer.frontdoor.id}" - method = "roundRobin" - persistence = "standard" - port = 80 - nodes - { - status = "enabled" - ipAddress = "${clc_server.node.private_ip_address}" - privatePort = 8000 - } + method = "roundRobin" + persistence = "standard" + port = 80 + + nodes { + status = "enabled" + ipAddress = "${clc_server.node.private_ip_address}" + privatePort = 8000 + } } diff --git a/examples/clc/outputs.tf b/examples/clc/outputs.tf index 1af6a4829..bfc751994 100644 --- a/examples/clc/outputs.tf +++ b/examples/clc/outputs.tf @@ -24,4 +24,4 @@ output "frontdoor" { output "pool" { value = "curl -vv ${clc_load_balancer.frontdoor.ip_address}" -} \ No newline at end of file +} diff --git a/examples/clc/variables.tf b/examples/clc/variables.tf index 626794bc9..5bba78595 100644 --- a/examples/clc/variables.tf +++ b/examples/clc/variables.tf @@ -1,6 +1,7 @@ variable "clc_username" { default = "" } + variable "clc_password" { default = "" } @@ -16,4 +17,4 @@ variable "image" { variable "app_port" { default = 8080 -} \ No newline at end of file +} diff --git a/examples/consul/main.tf b/examples/consul/main.tf index 9290d834e..3d81806ff 100644 --- a/examples/consul/main.tf +++ b/examples/consul/main.tf @@ -1,6 +1,6 @@ # Setup the Consul provisioner to use the demo cluster provider "consul" { - address = "demo.consul.io:80" + address = "demo.consul.io:80" datacenter = "nyc1" } @@ -12,8 +12,8 @@ provider "aws" { # Setup a key in Consul to provide inputs resource "consul_keys" "input" { key { - name = "size" - path = "tf_test/size" + name = "size" + path = "tf_test/size" default = "m1.small" } } @@ -21,7 +21,7 @@ resource "consul_keys" "input" { # Setup a new AWS instance using a dynamic ami and # instance type resource "aws_instance" "test" { - ami = "${lookup(var.aws_amis, var.aws_region)}" + ami = "${lookup(var.aws_amis, var.aws_region)}" instance_type = "${consul_keys.input.var.size}" } @@ -29,15 +29,16 @@ resource "aws_instance" "test" { # the DNS name of the instance resource "consul_keys" "test" { key { - name = "id" - path = "tf_test/id" - value = "${aws_instance.test.id}" + name = "id" + path = "tf_test/id" + value = "${aws_instance.test.id}" delete = true } + key { - name = "address" - path = "tf_test/public_dns" - value = "${aws_instance.test.public_dns}" + name = "address" + path = "tf_test/public_dns" + value = "${aws_instance.test.public_dns}" delete = true } } diff --git a/examples/consul/variables.tf b/examples/consul/variables.tf index e56955c1c..2cb9be01c 100644 --- a/examples/consul/variables.tf +++ b/examples/consul/variables.tf @@ -1,14 +1,14 @@ variable "aws_region" { description = "The AWS region to create resources in." - default = "us-east-1" + default = "us-east-1" } # AMI's from http://cloud-images.ubuntu.com/locator/ec2/ variable "aws_amis" { default = { - eu-west-1 = "ami-b1cf19c6" - us-east-1 = "ami-de7ab6b6" - us-west-1 = "ami-3f75767a" - us-west-2 = "ami-21f78e11" + eu-west-1 = "ami-b1cf19c6" + us-east-1 = "ami-de7ab6b6" + us-west-1 = "ami-3f75767a" + us-west-2 = "ami-21f78e11" } } diff --git a/examples/cross-provider/main.tf b/examples/cross-provider/main.tf index cac08178f..05c53c507 100644 --- a/examples/cross-provider/main.tf +++ b/examples/cross-provider/main.tf @@ -14,13 +14,13 @@ resource "dnsimple_record" "web" { value = "${heroku_app.web.heroku_hostname}" type = "CNAME" - ttl = 3600 + ttl = 3600 } # The Heroku domain, which will be created and added # to the heroku application after we have assigned the domain # in DNSimple resource "heroku_domain" "foobar" { - app = "${heroku_app.web.name}" + app = "${heroku_app.web.name}" hostname = "${dnsimple_record.web.hostname}" } diff --git a/examples/digitalocean/main.tf b/examples/digitalocean/main.tf index ec1b25fc1..5753295cd 100644 --- a/examples/digitalocean/main.tf +++ b/examples/digitalocean/main.tf @@ -1,43 +1,44 @@ provider "digitalocean" { -# You need to set this in your .bashrc -# export DIGITALOCEAN_TOKEN="Your API TOKEN" -# + # You need to set this in your .bashrc + # export DIGITALOCEAN_TOKEN="Your API TOKEN" + # } resource "digitalocean_droplet" "mywebserver" { - # Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys - ssh_keys=[12345678] # Key example - image = "${var.ubuntu}" - region = "${var.do_ams3}" - size = "512mb" - private_networking = true - backups = true - ipv6 = true - name = "mywebserver-ams3" + # Obtain your ssh_key id number via your account. See Document https://developers.digitalocean.com/documentation/v2/#list-all-keys + ssh_keys = [12345678] # Key example + image = "${var.ubuntu}" + region = "${var.do_ams3}" + size = "512mb" + private_networking = true + backups = true + ipv6 = true + name = "mywebserver-ams3" - provisioner "remote-exec" { - inline = [ - "export PATH=$PATH:/usr/bin", - "sudo apt-get update", - "sudo apt-get -y install nginx" - ] - connection { - type = "ssh" - key_file = "file(${HOME}/.ssh/id_rsa)" - user = "root" - timeout = "2m" - } - } + provisioner "remote-exec" { + inline = [ + "export PATH=$PATH:/usr/bin", + "sudo apt-get update", + "sudo apt-get -y install nginx", + ] + + connection { + type = "ssh" + key_file = "file(${HOME}/.ssh/id_rsa)" + user = "root" + timeout = "2m" + } + } } resource "digitalocean_domain" "mywebserver" { - name = "www.mywebserver.com" - ip_address = "${digitalocean_droplet.mywebserver.ipv4_address}" + name = "www.mywebserver.com" + ip_address = "${digitalocean_droplet.mywebserver.ipv4_address}" } resource "digitalocean_record" "mywebserver" { - domain = "${digitalocean_domain.mywebserver.name}" - type = "A" - name = "mywebserver" - value = "${digitalocean_droplet.mywebserver.ipv4_address}" + domain = "${digitalocean_domain.mywebserver.name}" + type = "A" + name = "mywebserver" + value = "${digitalocean_droplet.mywebserver.ipv4_address}" } diff --git a/examples/digitalocean/outputs.tf b/examples/digitalocean/outputs.tf index 689d40a69..8c7e627ac 100644 --- a/examples/digitalocean/outputs.tf +++ b/examples/digitalocean/outputs.tf @@ -1,7 +1,7 @@ output "Public ip" { - value = "${digitalocean_droplet.mywebserver.ipv4_address}" + value = "${digitalocean_droplet.mywebserver.ipv4_address}" } output "Name" { - value = "${digitalocean_droplet.mywebserver.name}" + value = "${digitalocean_droplet.mywebserver.name}" } diff --git a/examples/digitalocean/variable.tf b/examples/digitalocean/variable.tf index 0382c15b5..179b8d803 100644 --- a/examples/digitalocean/variable.tf +++ b/examples/digitalocean/variable.tf @@ -1,71 +1,74 @@ # #### + # Current Availiable Datacenter Regions + # As of 05-07-2016 + # variable "do_ams2" { - description = "Digital Ocean Amsterdam Data Center 2" - default = "ams2" + description = "Digital Ocean Amsterdam Data Center 2" + default = "ams2" } variable "do_ams3" { - description = "Digital Ocean Amsterdam Data Center 3" - default = "ams3" + description = "Digital Ocean Amsterdam Data Center 3" + default = "ams3" } variable "do_fra1" { - description = "Digital Ocean Frankfurt Data Center 1" - default = "fra1" + description = "Digital Ocean Frankfurt Data Center 1" + default = "fra1" } variable "do_lon1" { - description = "Digital Ocean London Data Center 1" - default = "lon1" + description = "Digital Ocean London Data Center 1" + default = "lon1" } variable "do_nyc1" { - description = "Digital Ocean New York Data Center 1" - default = "nyc1" + description = "Digital Ocean New York Data Center 1" + default = "nyc1" } variable "do_nyc2" { - description = "Digital Ocean New York Data Center 2" - default = "nyc2" + description = "Digital Ocean New York Data Center 2" + default = "nyc2" } variable "do_nyc3" { - description = "Digital Ocean New York Data Center 3" - default = "nyc3" + description = "Digital Ocean New York Data Center 3" + default = "nyc3" } variable "do_sfo1" { - description = "Digital Ocean San Francisco Data Center 1" - default = "sfo1" + description = "Digital Ocean San Francisco Data Center 1" + default = "sfo1" } variable "do_sgp1" { - description = "Digital Ocean Singapore Data Center 1" - default = "sgp1" + description = "Digital Ocean Singapore Data Center 1" + default = "sgp1" } variable "do_tor1" { - description = "Digital Ocean Toronto Datacenter 1" - default = "tor1" + description = "Digital Ocean Toronto Datacenter 1" + default = "tor1" } # Default Os variable "ubuntu" { - description = "Default LTS" - default = "ubuntu-14-04-x64" + description = "Default LTS" + default = "ubuntu-14-04-x64" } variable "centos" { - description = "Default Centos" - default = "centos-72-x64" + description = "Default Centos" + default = "centos-72-x64" } variable "coreos" { - description = "Defaut Coreos" - default = "coreos-899.17.0" + description = "Defaut Coreos" + default = "coreos-899.17.0" } diff --git a/examples/gce-vpn/variables.tf b/examples/gce-vpn/variables.tf index 20ada06bb..574e13d31 100644 --- a/examples/gce-vpn/variables.tf +++ b/examples/gce-vpn/variables.tf @@ -1,11 +1,11 @@ variable "project" { - description = "Your project name" + description = "Your project name" } variable "region1" { - description = "The desired region for the first network & VPN and project" + description = "The desired region for the first network & VPN and project" } variable "region2" { - description = "The desired region for the second network & VPN" + description = "The desired region for the second network & VPN" } diff --git a/examples/gce-vpn/vpn.tf b/examples/gce-vpn/vpn.tf index 23fa8a02c..d9f86cbc7 100644 --- a/examples/gce-vpn/vpn.tf +++ b/examples/gce-vpn/vpn.tf @@ -1,172 +1,182 @@ # An example of how to connect two GCE networks with a VPN provider "google" { - account_file = "${file("~/gce/account.json")}" - project = "${var.project}" - region = "${var.region1}" + account_file = "${file("~/gce/account.json")}" + project = "${var.project}" + region = "${var.region1}" } # Create the two networks we want to join. They must have seperate, internal # ranges. resource "google_compute_network" "network1" { - name = "network1" - ipv4_range = "10.120.0.0/16" + name = "network1" + ipv4_range = "10.120.0.0/16" } resource "google_compute_network" "network2" { - name = "network2" - ipv4_range = "10.121.0.0/16" + name = "network2" + ipv4_range = "10.121.0.0/16" } # Attach a VPN gateway to each network. resource "google_compute_vpn_gateway" "target_gateway1" { - name = "vpn1" - network = "${google_compute_network.network1.self_link}" - region = "${var.region1}" + name = "vpn1" + network = "${google_compute_network.network1.self_link}" + region = "${var.region1}" } resource "google_compute_vpn_gateway" "target_gateway2" { - name = "vpn2" - network = "${google_compute_network.network2.self_link}" - region = "${var.region2}" + name = "vpn2" + network = "${google_compute_network.network2.self_link}" + region = "${var.region2}" } # Create an outward facing static IP for each VPN that will be used by the # other VPN to connect. resource "google_compute_address" "vpn_static_ip1" { - name = "vpn-static-ip1" - region = "${var.region1}" + name = "vpn-static-ip1" + region = "${var.region1}" } resource "google_compute_address" "vpn_static_ip2" { - name = "vpn-static-ip2" - region = "${var.region2}" + name = "vpn-static-ip2" + region = "${var.region2}" } # Forward IPSec traffic coming into our static IP to our VPN gateway. resource "google_compute_forwarding_rule" "fr1_esp" { - name = "fr1-esp" - region = "${var.region1}" - ip_protocol = "ESP" - ip_address = "${google_compute_address.vpn_static_ip1.address}" - target = "${google_compute_vpn_gateway.target_gateway1.self_link}" + name = "fr1-esp" + region = "${var.region1}" + ip_protocol = "ESP" + ip_address = "${google_compute_address.vpn_static_ip1.address}" + target = "${google_compute_vpn_gateway.target_gateway1.self_link}" } resource "google_compute_forwarding_rule" "fr2_esp" { - name = "fr2-esp" - region = "${var.region2}" - ip_protocol = "ESP" - ip_address = "${google_compute_address.vpn_static_ip2.address}" - target = "${google_compute_vpn_gateway.target_gateway2.self_link}" + name = "fr2-esp" + region = "${var.region2}" + ip_protocol = "ESP" + ip_address = "${google_compute_address.vpn_static_ip2.address}" + target = "${google_compute_vpn_gateway.target_gateway2.self_link}" } # The following two sets of forwarding rules are used as a part of the IPSec # protocol resource "google_compute_forwarding_rule" "fr1_udp500" { - name = "fr1-udp500" - region = "${var.region1}" - ip_protocol = "UDP" - port_range = "500" - ip_address = "${google_compute_address.vpn_static_ip1.address}" - target = "${google_compute_vpn_gateway.target_gateway1.self_link}" + name = "fr1-udp500" + region = "${var.region1}" + ip_protocol = "UDP" + port_range = "500" + ip_address = "${google_compute_address.vpn_static_ip1.address}" + target = "${google_compute_vpn_gateway.target_gateway1.self_link}" } resource "google_compute_forwarding_rule" "fr2_udp500" { - name = "fr2-udp500" - region = "${var.region2}" - ip_protocol = "UDP" - port_range = "500" - ip_address = "${google_compute_address.vpn_static_ip2.address}" - target = "${google_compute_vpn_gateway.target_gateway2.self_link}" + name = "fr2-udp500" + region = "${var.region2}" + ip_protocol = "UDP" + port_range = "500" + ip_address = "${google_compute_address.vpn_static_ip2.address}" + target = "${google_compute_vpn_gateway.target_gateway2.self_link}" } resource "google_compute_forwarding_rule" "fr1_udp4500" { - name = "fr1-udp4500" - region = "${var.region1}" - ip_protocol = "UDP" - port_range = "4500" - ip_address = "${google_compute_address.vpn_static_ip1.address}" - target = "${google_compute_vpn_gateway.target_gateway1.self_link}" + name = "fr1-udp4500" + region = "${var.region1}" + ip_protocol = "UDP" + port_range = "4500" + ip_address = "${google_compute_address.vpn_static_ip1.address}" + target = "${google_compute_vpn_gateway.target_gateway1.self_link}" } resource "google_compute_forwarding_rule" "fr2_udp4500" { - name = "fr2-udp4500" - region = "${var.region2}" - ip_protocol = "UDP" - port_range = "4500" - ip_address = "${google_compute_address.vpn_static_ip2.address}" - target = "${google_compute_vpn_gateway.target_gateway2.self_link}" + name = "fr2-udp4500" + region = "${var.region2}" + ip_protocol = "UDP" + port_range = "4500" + ip_address = "${google_compute_address.vpn_static_ip2.address}" + target = "${google_compute_vpn_gateway.target_gateway2.self_link}" } # Each tunnel is responsible for encrypting and decrypting traffic exiting # and leaving its associated gateway resource "google_compute_vpn_tunnel" "tunnel1" { - name = "tunnel1" - region = "${var.region1}" - peer_ip = "${google_compute_address.vpn_static_ip2.address}" - shared_secret = "a secret message" - target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway1.self_link}" - depends_on = ["google_compute_forwarding_rule.fr1_udp500", - "google_compute_forwarding_rule.fr1_udp4500", - "google_compute_forwarding_rule.fr1_esp"] + name = "tunnel1" + region = "${var.region1}" + peer_ip = "${google_compute_address.vpn_static_ip2.address}" + shared_secret = "a secret message" + target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway1.self_link}" + + depends_on = ["google_compute_forwarding_rule.fr1_udp500", + "google_compute_forwarding_rule.fr1_udp4500", + "google_compute_forwarding_rule.fr1_esp", + ] } resource "google_compute_vpn_tunnel" "tunnel2" { - name = "tunnel2" - region = "${var.region2}" - peer_ip = "${google_compute_address.vpn_static_ip1.address}" - shared_secret = "a secret message" - target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway2.self_link}" - depends_on = ["google_compute_forwarding_rule.fr2_udp500", - "google_compute_forwarding_rule.fr2_udp4500", - "google_compute_forwarding_rule.fr2_esp"] + name = "tunnel2" + region = "${var.region2}" + peer_ip = "${google_compute_address.vpn_static_ip1.address}" + shared_secret = "a secret message" + target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway2.self_link}" + + depends_on = ["google_compute_forwarding_rule.fr2_udp500", + "google_compute_forwarding_rule.fr2_udp4500", + "google_compute_forwarding_rule.fr2_esp", + ] } # Each route tells the associated network to send all traffic in the dest_range # through the VPN tunnel resource "google_compute_route" "route1" { - name = "route1" - network = "${google_compute_network.network1.name}" - next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" - dest_range = "${google_compute_network.network2.ipv4_range}" - priority = 1000 + name = "route1" + network = "${google_compute_network.network1.name}" + next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel1.self_link}" + dest_range = "${google_compute_network.network2.ipv4_range}" + priority = 1000 } resource "google_compute_route" "route2" { - name = "route2" - network = "${google_compute_network.network2.name}" - next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel2.self_link}" - dest_range = "${google_compute_network.network1.ipv4_range}" - priority = 1000 + name = "route2" + network = "${google_compute_network.network2.name}" + next_hop_vpn_tunnel = "${google_compute_vpn_tunnel.tunnel2.self_link}" + dest_range = "${google_compute_network.network1.ipv4_range}" + priority = 1000 } # We want to allow the two networks to communicate, so we need to unblock # them in the firewall resource "google_compute_firewall" "network1-allow-network1" { - name = "network1-allow-network1" - network = "${google_compute_network.network1.name}" - source_ranges = ["${google_compute_network.network1.ipv4_range}"] - allow { - protocol = "tcp" - } - allow { - protocol = "udp" - } - allow { - protocol = "icmp" - } + name = "network1-allow-network1" + network = "${google_compute_network.network1.name}" + source_ranges = ["${google_compute_network.network1.ipv4_range}"] + + allow { + protocol = "tcp" + } + + allow { + protocol = "udp" + } + + allow { + protocol = "icmp" + } } resource "google_compute_firewall" "network1-allow-network2" { - name = "network1-allow-network2" - network = "${google_compute_network.network1.name}" - source_ranges = ["${google_compute_network.network2.ipv4_range}"] - allow { - protocol = "tcp" - } - allow { - protocol = "udp" - } - allow { - protocol = "icmp" - } + name = "network1-allow-network2" + network = "${google_compute_network.network1.name}" + source_ranges = ["${google_compute_network.network2.ipv4_range}"] + + allow { + protocol = "tcp" + } + + allow { + protocol = "udp" + } + + allow { + protocol = "icmp" + } } diff --git a/examples/google-two-tier/main.tf b/examples/google-two-tier/main.tf index 6e550060c..f3cb3e39a 100644 --- a/examples/google-two-tier/main.tf +++ b/examples/google-two-tier/main.tf @@ -1,39 +1,39 @@ # See https://cloud.google.com/compute/docs/load-balancing/network/example provider "google" { - region = "${var.region}" - project = "${var.project_name}" + region = "${var.region}" + project = "${var.project_name}" credentials = "${file("${var.credentials_file_path}")}" } resource "google_compute_http_health_check" "default" { - name = "tf-www-basic-check" - request_path = "/" - check_interval_sec = 1 - healthy_threshold = 1 + name = "tf-www-basic-check" + request_path = "/" + check_interval_sec = 1 + healthy_threshold = 1 unhealthy_threshold = 10 - timeout_sec = 1 + timeout_sec = 1 } resource "google_compute_target_pool" "default" { - name = "tf-www-target-pool" - instances = ["${google_compute_instance.www.*.self_link}"] + name = "tf-www-target-pool" + instances = ["${google_compute_instance.www.*.self_link}"] health_checks = ["${google_compute_http_health_check.default.name}"] } resource "google_compute_forwarding_rule" "default" { - name = "tf-www-forwarding-rule" - target = "${google_compute_target_pool.default.self_link}" + name = "tf-www-forwarding-rule" + target = "${google_compute_target_pool.default.self_link}" port_range = "80" } resource "google_compute_instance" "www" { count = 3 - name = "tf-www-${count.index}" + name = "tf-www-${count.index}" machine_type = "f1-micro" - zone = "${var.region_zone}" - tags = ["www-node"] + zone = "${var.region_zone}" + tags = ["www-node"] disk { image = "ubuntu-os-cloud/ubuntu-1404-trusty-v20160602" @@ -41,6 +41,7 @@ resource "google_compute_instance" "www" { network_interface { network = "default" + access_config { # Ephemeral } @@ -51,26 +52,28 @@ resource "google_compute_instance" "www" { } provisioner "file" { - source = "${var.install_script_src_path}" + source = "${var.install_script_src_path}" destination = "${var.install_script_dest_path}" + connection { - type = "ssh" - user = "root" + type = "ssh" + user = "root" private_key = "${file("${var.private_key_path}")}" - agent = false + agent = false } } provisioner "remote-exec" { connection { - type = "ssh" - user = "root" + type = "ssh" + user = "root" private_key = "${file("${var.private_key_path}")}" - agent = false + agent = false } + inline = [ "chmod +x ${var.install_script_dest_path}", - "sudo ${var.install_script_dest_path} ${count.index}" + "sudo ${var.install_script_dest_path} ${count.index}", ] } @@ -80,14 +83,14 @@ resource "google_compute_instance" "www" { } resource "google_compute_firewall" "default" { - name = "tf-www-firewall" + name = "tf-www-firewall" network = "default" allow { protocol = "tcp" - ports = ["80"] + ports = ["80"] } source_ranges = ["0.0.0.0/0"] - target_tags = ["www-node"] + target_tags = ["www-node"] } diff --git a/examples/google-two-tier/variables.tf b/examples/google-two-tier/variables.tf index 65fb11bcf..8bda69927 100644 --- a/examples/google-two-tier/variables.tf +++ b/examples/google-two-tier/variables.tf @@ -12,25 +12,25 @@ variable "project_name" { variable "credentials_file_path" { description = "Path to the JSON file used to describe your account credentials" - default = "~/.gcloud/Terraform.json" + default = "~/.gcloud/Terraform.json" } variable "public_key_path" { description = "Path to file containing public key" - default = "~/.ssh/gcloud_id_rsa.pub" + default = "~/.ssh/gcloud_id_rsa.pub" } variable "private_key_path" { description = "Path to file containing private key" - default = "~/.ssh/gcloud_id_rsa" + default = "~/.ssh/gcloud_id_rsa" } variable "install_script_src_path" { description = "Path to install script within this repository" - default = "scripts/install.sh" + default = "scripts/install.sh" } variable "install_script_dest_path" { description = "Path to put the install script on each destination resource" - default = "/tmp/install.sh" + default = "/tmp/install.sh" } diff --git a/examples/openstack-with-networking/main.tf b/examples/openstack-with-networking/main.tf index d57925263..d91bca0b9 100644 --- a/examples/openstack-with-networking/main.tf +++ b/examples/openstack-with-networking/main.tf @@ -1,24 +1,24 @@ resource "openstack_compute_keypair_v2" "terraform" { - name = "terraform" + name = "terraform" public_key = "${file("${var.ssh_key_file}.pub")}" } resource "openstack_networking_network_v2" "terraform" { - name = "terraform" + name = "terraform" admin_state_up = "true" } resource "openstack_networking_subnet_v2" "terraform" { - name = "terraform" - network_id = "${openstack_networking_network_v2.terraform.id}" - cidr = "10.0.0.0/24" - ip_version = 4 - dns_nameservers = ["8.8.8.8","8.8.4.4"] + name = "terraform" + network_id = "${openstack_networking_network_v2.terraform.id}" + cidr = "10.0.0.0/24" + ip_version = 4 + dns_nameservers = ["8.8.8.8", "8.8.4.4"] } resource "openstack_networking_router_v2" "terraform" { - name = "terraform" - admin_state_up = "true" + name = "terraform" + admin_state_up = "true" external_gateway = "${var.external_gateway}" } @@ -28,52 +28,58 @@ resource "openstack_networking_router_interface_v2" "terraform" { } resource "openstack_compute_secgroup_v2" "terraform" { - name = "terraform" + name = "terraform" description = "Security group for the Terraform example instances" + rule { - from_port = 22 - to_port = 22 + from_port = 22 + to_port = 22 ip_protocol = "tcp" - cidr = "0.0.0.0/0" + cidr = "0.0.0.0/0" } + rule { - from_port = 80 - to_port = 80 + from_port = 80 + to_port = 80 ip_protocol = "tcp" - cidr = "0.0.0.0/0" + cidr = "0.0.0.0/0" } + rule { - from_port = -1 - to_port = -1 + from_port = -1 + to_port = -1 ip_protocol = "icmp" - cidr = "0.0.0.0/0" + cidr = "0.0.0.0/0" } } resource "openstack_compute_floatingip_v2" "terraform" { - pool = "${var.pool}" + pool = "${var.pool}" depends_on = ["openstack_networking_router_interface_v2.terraform"] } resource "openstack_compute_instance_v2" "terraform" { - name = "terraform" - image_name = "${var.image}" - flavor_name = "${var.flavor}" - key_pair = "${openstack_compute_keypair_v2.terraform.name}" - security_groups = [ "${openstack_compute_secgroup_v2.terraform.name}" ] - floating_ip = "${openstack_compute_floatingip_v2.terraform.address}" + name = "terraform" + image_name = "${var.image}" + flavor_name = "${var.flavor}" + key_pair = "${openstack_compute_keypair_v2.terraform.name}" + security_groups = ["${openstack_compute_secgroup_v2.terraform.name}"] + floating_ip = "${openstack_compute_floatingip_v2.terraform.address}" + network { uuid = "${openstack_networking_network_v2.terraform.id}" } + provisioner "remote-exec" { connection { - user = "${var.ssh_user_name}" + user = "${var.ssh_user_name}" key_file = "${var.ssh_key_file}" } + inline = [ - "sudo apt-get -y update", - "sudo apt-get -y install nginx", - "sudo service nginx start" + "sudo apt-get -y update", + "sudo apt-get -y install nginx", + "sudo service nginx start", ] } } diff --git a/examples/openstack-with-networking/outputs.tf b/examples/openstack-with-networking/outputs.tf index 42f923fe2..8ff1f75a7 100644 --- a/examples/openstack-with-networking/outputs.tf +++ b/examples/openstack-with-networking/outputs.tf @@ -1,3 +1,3 @@ output "address" { - value = "${openstack_compute_floatingip_v2.terraform.address}" + value = "${openstack_compute_floatingip_v2.terraform.address}" } diff --git a/examples/openstack-with-networking/variables.tf b/examples/openstack-with-networking/variables.tf index 3477cf67e..c24a6958a 100644 --- a/examples/openstack-with-networking/variables.tf +++ b/examples/openstack-with-networking/variables.tf @@ -1,22 +1,21 @@ variable "image" { - default = "Ubuntu 14.04" + default = "Ubuntu 14.04" } variable "flavor" { - default = "m1.small" + default = "m1.small" } variable "ssh_key_file" { - default = "~/.ssh/id_rsa.terraform" + default = "~/.ssh/id_rsa.terraform" } variable "ssh_user_name" { - default = "ubuntu" + default = "ubuntu" } -variable "external_gateway" { -} +variable "external_gateway" {} variable "pool" { - default = "public" + default = "public" }