generated from mentoriaiac/template-modulo-terraform
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from lgfa29/update-refactor
feat: reorganização de arquivos e atualizações
- Loading branch information
Showing
6 changed files
with
118 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
data "google_compute_zones" "us-central1" { | ||
region = var.region | ||
} | ||
|
||
module "nomad_clients" { | ||
source = "github.com/mentoriaiac/iac-modulo-compute-gcp.git?ref=v0.2.1" | ||
count = 2 | ||
|
||
project = var.project | ||
zone = data.google_compute_zones.us-central1.names[count.index % length(data.google_compute_zones.us-central1.names)] | ||
|
||
instance_name = "client-${count.index + 1}" | ||
instance_image = "nomad-v0-3-0" | ||
machine_type = "e2-small" | ||
|
||
network = module.network_gcp.vpc_id | ||
subnetwork = module.network_gcp.subnets[0].id | ||
tags = ["nomad", "consul"] | ||
|
||
metadata_startup_script = <<EOF | ||
/usr/local/bin/nomad_bootstrap.sh client '\"provider=gce project_name=${var.project} tag_value=nomad-server\"' global dc1 nomad-ca-cert:1 nomad-client-cert:1 nomad-client-key:1 | ||
/usr/local/bin/consul_bootstrap.sh agent '\"provider=gce project_name=${var.project} tag_value=consul\"' | ||
EOF | ||
|
||
roles = [ | ||
"roles/secretmanager.secretAccessor", | ||
"roles/compute.viewer", | ||
] | ||
|
||
labels = { | ||
terraform = "true", | ||
component = "nomad_client" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,99 +1,4 @@ | ||
# colocar a chamada do módulo aqui | ||
|
||
## Exemplo | ||
|
||
provider "google" { | ||
project = var.project | ||
region = var.region | ||
} | ||
|
||
module "network_gcp" { | ||
source = "github.com/mentoriaiac/iac-modulo-rede-gcp.git?ref=v0.2.0" | ||
project = var.project | ||
region = var.region | ||
vpc_name = "rede-mentoria" | ||
direction = "INGRESS" | ||
target_tags = ["nomad", "consul"] | ||
source_tags = ["nomad", "consul"] | ||
subnetworks = [ | ||
{ | ||
name = "subnet-nomad" | ||
ip_cidr_range = "10.0.0.0/16" | ||
region = var.region | ||
} | ||
] | ||
|
||
firewall_allow = [ | ||
{ | ||
protocol = "tcp" | ||
port = [ | ||
22, | ||
# Nomad | ||
4646, 4647, 4648, | ||
# Consul | ||
"8300-8302", "8500-8502", 8600, "21000-21255", | ||
] | ||
} | ||
] | ||
} | ||
|
||
module "nomad_servers" { | ||
source = "github.com/mentoriaiac/iac-modulo-compute-gcp.git?ref=v0.2.0" | ||
|
||
for_each = local.server_pool | ||
|
||
project = var.project | ||
instance_name = each.key | ||
instance_image = each.value.instance_image | ||
machine_type = each.value.machine_type | ||
zone = each.value.zone | ||
network = module.network_gcp.vpc_id | ||
subnetwork = module.network_gcp.subnets[0].id | ||
metadata_startup_script = <<EOF | ||
/usr/local/bin/nomad_bootstrap.sh server 3 '\"provider=gce project_name=${var.project} tag_value=nomad-server\"' | ||
/usr/local/bin/consul_bootstrap.sh server 3 '\"provider=gce project_name=${var.project} tag_value=consul\"' | ||
EOF | ||
tags = ["nomad", "nomad-server", "consul"] | ||
labels = { | ||
terraform = "true", | ||
component = "nomad_server" | ||
} | ||
service_account_scopes = [ | ||
"https://www.googleapis.com/auth/compute.readonly", | ||
] | ||
} | ||
|
||
|
||
data "google_compute_zones" "us-central1" { | ||
# project = mentoria-terraform | ||
region = var.region | ||
} | ||
|
||
module "nomad_clients" { | ||
source = "github.com/mentoriaiac/iac-modulo-compute-gcp.git?ref=v0.2.0" | ||
|
||
count = 3 | ||
|
||
project = var.project | ||
instance_name = "client-${count.index + 1}" | ||
machine_type = "e2-medium" | ||
instance_image = "orquestradores-v0-2-0" | ||
zone = data.google_compute_zones.us-central1.names[count.index % length(data.google_compute_zones.us-central1.names)] | ||
network = module.network_gcp.vpc_id | ||
subnetwork = module.network_gcp.subnets[0].id | ||
metadata_startup_script = <<EOF | ||
/usr/local/bin/nomad_bootstrap.sh client '\"provider=gce project_name=${var.project} tag_value=nomad-server\"' | ||
/usr/local/bin/consul_bootstrap.sh agent '\"provider=gce project_name=${var.project} tag_value=consul\"' | ||
EOF | ||
|
||
service_account_scopes = [ | ||
"https://www.googleapis.com/auth/compute.readonly", | ||
] | ||
|
||
tags = ["nomad", "consul"] | ||
labels = { | ||
terraform = "true", | ||
component = "nomad_client" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module "network_gcp" { | ||
source = "github.com/mentoriaiac/iac-modulo-rede-gcp.git?ref=v0.2.0" | ||
|
||
project = var.project | ||
region = var.region | ||
|
||
vpc_name = "rede-mentoria" | ||
direction = "INGRESS" | ||
|
||
target_tags = ["nomad", "consul"] | ||
source_tags = ["nomad", "consul"] | ||
|
||
subnetworks = [ | ||
{ | ||
name = "subnet-nomad" | ||
ip_cidr_range = "10.0.0.0/16" | ||
region = var.region | ||
} | ||
] | ||
|
||
firewall_allow = [ | ||
{ | ||
protocol = "tcp" | ||
port = [ | ||
22, | ||
# Nomad | ||
4646, 4647, 4648, | ||
# Consul | ||
"8300-8302", "8500-8502", 8600, "21000-21255", | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
locals { | ||
server_pool = { | ||
server-node-1 = { | ||
machine_type = "e2-small" | ||
instance_image = "nomad-v0-3-0" | ||
zone = "${var.region}-c" | ||
}, | ||
server-node-2 = { | ||
machine_type = "e2-small" | ||
instance_image = "nomad-v0-3-0" | ||
zone = "${var.region}-b" | ||
}, | ||
server-node-3 = { | ||
machine_type = "e2-small" | ||
instance_image = "nomad-v0-3-0" | ||
zone = "${var.region}-a" | ||
} | ||
} | ||
} | ||
|
||
module "nomad_servers" { | ||
source = "github.com/mentoriaiac/iac-modulo-compute-gcp.git?ref=v0.2.1" | ||
for_each = local.server_pool | ||
|
||
project = var.project | ||
zone = each.value.zone | ||
|
||
instance_name = each.key | ||
instance_image = each.value.instance_image | ||
machine_type = each.value.machine_type | ||
|
||
network = module.network_gcp.vpc_id | ||
subnetwork = module.network_gcp.subnets[0].id | ||
tags = ["nomad", "nomad-server", "consul"] | ||
|
||
metadata_startup_script = <<EOF | ||
/usr/local/bin/nomad_bootstrap.sh server 3 '\"provider=gce project_name=${var.project} tag_value=nomad-server\"' global dc1 nomad-ca-cert:1 nomad-server-cert:1 nomad-server-key:1 | ||
/usr/local/bin/consul_bootstrap.sh server 3 '\"provider=gce project_name=${var.project} tag_value=consul\"' | ||
EOF | ||
|
||
roles = [ | ||
"roles/secretmanager.secretAccessor", | ||
"roles/compute.viewer", | ||
] | ||
|
||
labels = { | ||
terraform = "true", | ||
component = "nomad_server" | ||
} | ||
} |