Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The terraform isn't formated correctly. terraform fmt -check=true fails. #4580

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 62 additions & 63 deletions terraform/aws/consul.tf
Original file line number Diff line number Diff line change
@@ -1,77 +1,76 @@
resource "aws_instance" "server" {
ami = "${lookup(var.ami, "${var.region}-${var.platform}")}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
count = "${var.servers}"
security_groups = ["${aws_security_group.consul.id}"]
subnet_id = "${lookup(var.subnets, count.index % var.servers)}"
ami = "${lookup(var.ami, "${var.region}-${var.platform}")}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
count = "${var.servers}"
security_groups = ["${aws_security_group.consul.id}"]
subnet_id = "${lookup(var.subnets, count.index % var.servers)}"

connection {
user = "${lookup(var.user, var.platform)}"
private_key = "${file("${var.key_path}")}"
}
connection {
user = "${lookup(var.user, var.platform)}"
private_key = "${file("${var.key_path}")}"
}

#Instance tags
tags {
Name = "${var.tagName}-${count.index}"
ConsulRole = "Server"
}
#Instance tags
tags {
Name = "${var.tagName}-${count.index}"
ConsulRole = "Server"
}

provisioner "file" {
source = "${path.module}/../shared/scripts/${lookup(var.service_conf, var.platform)}"
destination = "/tmp/${lookup(var.service_conf_dest, var.platform)}"
}
provisioner "file" {
source = "${path.module}/../shared/scripts/${lookup(var.service_conf, var.platform)}"
destination = "/tmp/${lookup(var.service_conf_dest, var.platform)}"
}

provisioner "remote-exec" {
inline = [
"echo ${var.servers} > /tmp/consul-server-count",
"echo ${aws_instance.server.0.private_ip} > /tmp/consul-server-addr",
]
}

provisioner "remote-exec" {
inline = [
"echo ${var.servers} > /tmp/consul-server-count",
"echo ${aws_instance.server.0.private_ip} > /tmp/consul-server-addr",
]
}

provisioner "remote-exec" {
scripts = [
"${path.module}/../shared/scripts/install.sh",
"${path.module}/../shared/scripts/service.sh",
"${path.module}/../shared/scripts/ip_tables.sh",
]
}
provisioner "remote-exec" {
scripts = [
"${path.module}/../shared/scripts/install.sh",
"${path.module}/../shared/scripts/service.sh",
"${path.module}/../shared/scripts/ip_tables.sh",
]
}
}

resource "aws_security_group" "consul" {
name = "consul_${var.platform}"
description = "Consul internal traffic + maintenance."
vpc_id = "${var.vpc_id}"
name = "consul_${var.platform}"
description = "Consul internal traffic + maintenance."
vpc_id = "${var.vpc_id}"

// These are for internal traffic
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
self = true
}
// These are for internal traffic
ingress {
from_port = 0
to_port = 65535
protocol = "tcp"
self = true
}

ingress {
from_port = 0
to_port = 65535
protocol = "udp"
self = true
}
ingress {
from_port = 0
to_port = 65535
protocol = "udp"
self = true
}

// These are for maintenance
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
// These are for maintenance
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}

// This is for outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
// This is for outbound internet access
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
2 changes: 1 addition & 1 deletion terraform/aws/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
output "server_address" {
value = "${aws_instance.server.0.public_dns}"
value = "${aws_instance.server.0.public_dns}"
}
26 changes: 13 additions & 13 deletions terraform/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ variable "ami" {
description = "AWS AMI Id, if you change, make sure it is compatible with instance type, not all AMIs allow all instance types "

default = {
ap-south-1-ubuntu = "ami-08a5e367"
us-east-1-ubuntu = "ami-d651b8ac"
ap-south-1-ubuntu = "ami-08a5e367"
us-east-1-ubuntu = "ami-d651b8ac"
ap-northeast-1-ubuntu = "ami-8422ebe2"
eu-west-1-ubuntu = "ami-17d11e6e"
eu-west-1-ubuntu = "ami-17d11e6e"
ap-southeast-1-ubuntu = "ami-e6d3a585"
ca-central-1-ubuntu = "ami-e59c2581"
us-west-1-ubuntu = "ami-2d5c6d4d"
eu-central-1-ubuntu = "ami-5a922335"
sa-east-1-ubuntu = "ami-a3e39ecf"
ca-central-1-ubuntu = "ami-e59c2581"
us-west-1-ubuntu = "ami-2d5c6d4d"
eu-central-1-ubuntu = "ami-5a922335"
sa-east-1-ubuntu = "ami-a3e39ecf"
ap-southeast-2-ubuntu = "ami-391ff95b"
eu-west-2-ubuntu = "ami-e1f2e185"
eu-west-2-ubuntu = "ami-e1f2e185"
ap-northeast-2-ubuntu = "ami-0f6fb461"
us-west-2-ubuntu = "ami-ecc63a94"
us-east-2-ubuntu = "ami-9686a4f3"
us-west-2-ubuntu = "ami-ecc63a94"
us-east-2-ubuntu = "ami-9686a4f3"
us-east-1-rhel6 = "ami-0d28fe66"
us-east-2-rhel6 = "ami-aff2a9ca"
us-west-2-rhel6 = "ami-3d3c0a0d"
Expand Down Expand Up @@ -95,11 +95,11 @@ variable "tagName" {
}

variable "subnets" {
type = "map"
type = "map"
description = "map of subnets to deploy your infrastructure in, must have as many keys as your server count (default 3), -var 'subnets={\"0\"=\"subnet-12345\",\"1\"=\"subnets-23456\"}' "
}

variable "vpc_id" {
type = "string"
type = "string"
description = "ID of the VPC to use - in case your account doesn't have default VPC"
}
}
101 changes: 51 additions & 50 deletions terraform/google/consul.tf
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
resource "google_compute_instance" "consul" {
count = "${var.servers}"
count = "${var.servers}"

name = "consul-${count.index}"
zone = "${var.region_zone}"
tags = ["${var.tag_name}"]
name = "consul-${count.index}"
zone = "${var.region_zone}"
tags = ["${var.tag_name}"]

machine_type = "${var.machine_type}"
machine_type = "${var.machine_type}"

disk {
image = "${lookup(var.machine_image, var.platform)}"
}
disk {
image = "${lookup(var.machine_image, var.platform)}"
}

network_interface {
network = "default"
network_interface {
network = "default"

access_config {
# Ephemeral
}
access_config {
# Ephemeral
}
}

service_account {
scopes = ["https://www.googleapis.com/auth/compute.readonly"]
}
service_account {
scopes = ["https://www.googleapis.com/auth/compute.readonly"]
}

connection {
user = "${lookup(var.user, var.platform)}"
private_key = "${file("${var.key_path}")}"
}
connection {
user = "${lookup(var.user, var.platform)}"
private_key = "${file("${var.key_path}")}"
}

provisioner "file" {
source = "${path.module}/../shared/scripts/${lookup(var.service_conf, var.platform)}"
destination = "/tmp/${lookup(var.service_conf_dest, var.platform)}"
}
provisioner "file" {
source = "${path.module}/../shared/scripts/${lookup(var.service_conf, var.platform)}"
destination = "/tmp/${lookup(var.service_conf_dest, var.platform)}"
}

provisioner "remote-exec" {
inline = [
"echo ${var.servers} > /tmp/consul-server-count",
"echo ${google_compute_instance.consul.0.network_interface.0.address} > /tmp/consul-server-addr",
]
}
provisioner "remote-exec" {
inline = [
"echo ${var.servers} > /tmp/consul-server-count",
"echo ${google_compute_instance.consul.0.network_interface.0.address} > /tmp/consul-server-addr",
]
}

provisioner "remote-exec" {
scripts = [
"${path.module}/../shared/scripts/install.sh",
"${path.module}/../shared/scripts/service.sh",
"${path.module}/../shared/scripts/ip_tables.sh",
]
}
provisioner "remote-exec" {
scripts = [
"${path.module}/../shared/scripts/install.sh",
"${path.module}/../shared/scripts/service.sh",
"${path.module}/../shared/scripts/ip_tables.sh",
]
}
}

resource "google_compute_firewall" "consul_ingress" {
name = "consul-internal-access"
network = "default"
name = "consul-internal-access"
network = "default"

allow {
protocol = "tcp"
ports = [
"8300", # Server RPC
"8301", # Serf LAN
"8302", # Serf WAN
"8400", # RPC
]
}
allow {
protocol = "tcp"

ports = [
"8300", # Server RPC
"8301", # Serf LAN
"8302", # Serf WAN
"8400", # RPC
]
}

source_tags = ["${var.tag_name}"]
target_tags = ["${var.tag_name}"]
source_tags = ["${var.tag_name}"]
target_tags = ["${var.tag_name}"]
}
3 changes: 1 addition & 2 deletions terraform/google/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
output "server_address" {
value = "${google_compute_instance.consul.0.network_interface.0.address}"
value = "${google_compute_instance.consul.0.network_interface.0.address}"
}

Loading