This repository has been archived by the owner on Feb 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from cabify/add_module_to_add_gci_and_private_dns
Create module to add gci resources with private dns
- Loading branch information
Showing
3 changed files
with
102 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Terraform Google VM with r53 private dns | ||
|
||
Create a Google Compute Instance with a private DNS record in route53 | ||
|
||
### Example usage | ||
|
||
In the following example we're creating 3 nomad agent instances. | ||
|
||
``` | ||
module "nomad_agent" { | ||
source = "[email protected]:cabify/terraform-modules.git//google_vm_with_r53_private_dns?ref=1aac443ede51bc46a0a4b1d3493287e1537ade57" | ||
gce_zone = "${data.terraform_remote_state.testing.gce-zone}" | ||
component = "nomad" | ||
host_group = "nomad" | ||
instance_count = "3" | ||
aws_route53_zone_id = "${data.terraform_remote_state.testing.aws_route53_zone_id}" | ||
aws_route53_zone_name = "${data.terraform_remote_state.testing.aws_route53_zone_name}" | ||
machine_type = "n1-standard-1" | ||
google_deployer_ssh_public_key = "${data.terraform_remote_state.testing.google_deployer_ssh_public_key}" | ||
} | ||
``` |
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,45 @@ | ||
variable "gce_zone" { | ||
type = "string" | ||
default = "" | ||
} | ||
|
||
variable "aws_route53_zone_id" { | ||
type = "string" | ||
default = "" | ||
} | ||
|
||
variable "aws_route53_zone_name" { | ||
type = "string" | ||
default = "" | ||
} | ||
|
||
variable "component" { | ||
type = "string" | ||
default = "default_component" | ||
} | ||
|
||
variable "host_group" { | ||
type = "string" | ||
default = "default_host_group" | ||
} | ||
|
||
variable "instance_count" { | ||
type = "string" | ||
default = 0 | ||
} | ||
|
||
variable "machine_type" { | ||
type = "string" | ||
default = "n1-standard-1" | ||
} | ||
|
||
variable "os_image" { | ||
description = "OS GCE identifier" | ||
type = "string" | ||
default = "ubuntu-1404-lts" | ||
} | ||
|
||
variable "google_deployer_ssh_public_key" { | ||
type = "string" | ||
default = "" | ||
} |
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,36 @@ | ||
resource "google_compute_instance" "vm" { | ||
name = "${var.component}${count.index + 1}" | ||
machine_type = "${var.machine_type}" | ||
zone = "${var.gce_zone}" | ||
count = "${var.instance_count}" | ||
|
||
boot_disk { | ||
initialize_params { | ||
image = "${var.os_image}" | ||
} | ||
} | ||
|
||
scratch_disk {} | ||
|
||
network_interface { | ||
network = "default" | ||
|
||
access_config {} | ||
} | ||
|
||
metadata { | ||
host_group = "${var.host_group}" | ||
ssh-keys = "${var.google_deployer_ssh_public_key}" | ||
} | ||
} | ||
|
||
resource "aws_route53_record" "dns-int" { | ||
zone_id = "${var.aws_route53_zone_id}" | ||
name = "${var.component}${count.index + 1}.int.${var.aws_route53_zone_name}" | ||
type = "A" | ||
ttl = "60" | ||
count = "${var.instance_count}" | ||
|
||
// matches up record N to instance N | ||
records = ["${element(google_compute_instance.vm.*.network_interface.0.address,count.index)}"] | ||
} |