Skip to content

Commit

Permalink
Merge pull request #48 from Diaxion/customer-demo
Browse files Browse the repository at this point in the history
add additional tag support
  • Loading branch information
bnferguson authored Dec 18, 2019
2 parents 8e07503 + 0971aa8 commit 1a5249f
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
work/
work/
.idea
5 changes: 5 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module "common" {
vnet_name = "${var.virtual_network_name}"
subnet_name = "${var.subnet}"
resource_prefix = "${var.resource_prefix}"
additional_tags = "${var.additional_tags}"

key_type = "${var.tls_pfx_certificate_key_type}"
key_size = "${var.tls_pfx_certificate_key_size}"
Expand All @@ -30,6 +31,7 @@ module "cluster_lb" {
rg_name = "${module.common.rg_name}"
location = "${module.common.rg_location}"
resource_prefix = "${var.resource_prefix}"
additional_tags = "${var.additional_tags}"
hostname = "${var.hostname}"

dns = {
Expand Down Expand Up @@ -64,6 +66,7 @@ module "configs" {
weave_cidr = "${var.weave_cidr}"
repl_cidr = "${var.repl_cidr}"
release_sequence = "${var.release_sequence}"
additional_tags = "${var.additional_tags}"

iact = {
subnet_list = "${var.iact_subnet_list}"
Expand Down Expand Up @@ -100,6 +103,7 @@ module "primaries" {
subnet_id = "${module.common.app_subnet_id}"
resource_prefix = "${var.resource_prefix}"
external_services = "${var.postgresql_database == "" ? "False" : "True"}"
additional_tags = "${var.additional_tags}"

username = "${var.ssh_user}"
os_disk_size = "${var.os_disk_size}"
Expand Down Expand Up @@ -135,6 +139,7 @@ module "secondaries" {
cloud_init_data = "${module.configs.secondary_cloud_init}"
username = "${var.ssh_user}"
resource_prefix = "${var.resource_prefix}"
additional_tags = "${var.additional_tags}"

vm = {
size = "${local.rendered_secondary_vm_size}"
Expand Down
2 changes: 2 additions & 0 deletions modules/cluster_lb/dns.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resource "azurerm_dns_a_record" "api" {
resource_group_name = "${var.dns["rg_name"]}"
ttl = "${var.dns["ttl"]}"
records = ["${azurerm_public_ip.azlb.ip_address}"]
tags = "${local.tags}"
}

resource "azurerm_dns_a_record" "application" {
Expand All @@ -17,4 +18,5 @@ resource "azurerm_dns_a_record" "application" {
resource_group_name = "${var.dns["rg_name"]}"
ttl = "${var.dns["ttl"]}"
records = ["${azurerm_public_ip.azlb.ip_address}"]
tags = "${local.tags}"
}
2 changes: 2 additions & 0 deletions modules/cluster_lb/lb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ resource "azurerm_public_ip" "azlb" {
resource_group_name = "${var.rg_name}"
allocation_method = "Static"
sku = "Standard"
tags = "${local.tags}"
}

resource "azurerm_lb" "azlb" {
name = "${local.prefix}-lb"
resource_group_name = "${var.rg_name}"
location = "${var.location}"
sku = "Standard"
tags = "${local.tags}"

frontend_ip_configuration {
name = "${local.frontend}"
Expand Down
12 changes: 12 additions & 0 deletions modules/cluster_lb/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ variable "lb_probe_unhealthy_threshold" {
description = "The amount of unhealthy checks before marking a node unhealthy."
}

variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

variable "hostname" {
default = ""
description = "hostname for loadbalancer front end to use"
Expand All @@ -54,4 +60,10 @@ locals {
prefix = "${var.resource_prefix}-${var.install_id}"
frontend = "${local.prefix}-fe"
frontened_hostname = "${var.hostname != "" ? var.hostname : local.prefix }"

default_tags = {
Application = "Terraform Enterprise"
}

tags = "${merge(local.default_tags, var.additional_tags)}"
}
15 changes: 14 additions & 1 deletion modules/common/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,28 @@ variable "key_size" {
description = "Byte size for the key-pair used to generate the provided certificate"
}

# ============================================================ OPTIONAL

variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

# ============================================================ MISC

locals {
# path.root for remote modules to work properly.

ssh_public_key_path = "${path.root}/work"
key_name = "${var.resource_prefix}-${var.install_id}"
private_key_filename = "${local.ssh_public_key_path}/${local.key_name}.priv"
prefix = "${var.resource_prefix}-${var.install_id}"
rendered_kv_rg_name = "${coalesce(var.key_vault["rg_name"], var.rg_name)}"
rendered_domain_rg_name = "${coalesce(var.dns["rg_name"], var.rg_name)}"

default_tags = {
Application = "Terraform Enterprise"
}

tags = "${merge(local.default_tags, var.additional_tags)}"
}
6 changes: 6 additions & 0 deletions modules/configs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ variable "ca_bundle_url" {
description = "URL to CA certificate file used for the internal `ptfe-proxy` used for outgoing connections"
}

variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

# === Misc

locals {
Expand Down
5 changes: 1 addition & 4 deletions modules/primaries/nics.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource "azurerm_network_interface" "primary" {
name = "${local.prefix}-${count.index}"
resource_group_name = "${var.rg_name}"
location = "${var.location}"
tags = "${local.tags}"

ip_configuration {
name = "${local.ip_conf_name}"
Expand All @@ -11,10 +12,6 @@ resource "azurerm_network_interface" "primary" {
private_ip_address_allocation = "Dynamic"
primary = true
}

tags = {
"Name" = "${local.prefix}"
}
}

resource "azurerm_network_interface_backend_address_pool_association" "ptfe_api" {
Expand Down
5 changes: 1 addition & 4 deletions modules/primaries/public_ips.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ resource "azurerm_public_ip" "primary" {
resource_group_name = "${var.rg_name}"
allocation_method = "Static"
sku = "Standard"
tags = "${local.tags}"

lifecycle {
create_before_destroy = true
}

tags = {
"Name" = "${local.prefix}"
}
}
21 changes: 16 additions & 5 deletions modules/primaries/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,25 @@ variable "external_services" {
description = "Boolean string for whether or not to install in Internal Production Mode or External Services Mode"
}

# ============================================================ MISC
# ============================================================ OPTIONAL

locals {
prefix = "${var.resource_prefix}-${var.install_id}-primary"
variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

ip_conf_name = "${local.prefix}-ip-conf"
# ============================================================ MISC

locals {
prefix = "${var.resource_prefix}-${var.install_id}-primary"
ip_conf_name = "${local.prefix}-ip-conf"
ssh_config_path = "${path.root}/work/ssh_config"
install_type = "${var.external_services == "True" ? "es" : "ipm"}"

default_tags = {
Application = "Terraform Enterprise"
}

install_type = "${var.external_services == "True" ? "es" : "ipm"}"
tags = "${merge(local.default_tags, var.additional_tags)}"
}
5 changes: 1 addition & 4 deletions modules/primaries/vms.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resource "azurerm_virtual_machine" "primary" {
location = "${var.location}"
vm_size = "${var.vm["size"]}"
primary_network_interface_id = "${azurerm_network_interface.primary.*.id[count.index]}"
tags = "${local.tags}"

network_interface_ids = ["${azurerm_network_interface.primary.*.id[count.index]}"]
delete_os_disk_on_termination = true
Expand Down Expand Up @@ -50,8 +51,4 @@ resource "azurerm_virtual_machine" "primary" {
sku = "${var.storage_image["sku"]}"
version = "${var.storage_image["version"]}"
}

tags = {
"Name" = "${local.prefix}"
}
}
5 changes: 1 addition & 4 deletions modules/secondaries/scaleset.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ resource "azurerm_virtual_machine_scale_set" "secondary" {
resource_group_name = "${var.rg_name}"
location = "${var.location}"
upgrade_policy_mode = "Manual"
tags = "${local.tags}"

storage_profile_image_reference {
publisher = "${var.storage_image["publisher"]}"
Expand Down Expand Up @@ -49,8 +50,4 @@ resource "azurerm_virtual_machine_scale_set" "secondary" {
os_type = "Linux"
managed_disk_type = "StandardSSD_LRS"
}

tags = {
"Name" = "${local.prefix}"
}
}
14 changes: 14 additions & 0 deletions modules/secondaries/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,22 @@ variable "resource_prefix" {
description = "Prefix name for resources"
}

# ============================================================ OPTIONAL

variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

# === Misc

locals {
prefix = "${var.resource_prefix}-${var.install_id}"

default_tags = {
Application = "Terraform Enterprise"
}

tags = "${merge(local.default_tags, var.additional_tags)}"
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,9 @@ variable "repl_cidr" {
description = "Specify a non-standard CIDR range for the replicated services. The default is 10.96.0.0/12"
default = ""
}

variable "additional_tags" {
type = "map"
description = "A map of additional tags to attach to all resources created."
default = {}
}

0 comments on commit 1a5249f

Please sign in to comment.