Commit 51b8e3b9 authored by Daniele Valeriani's avatar Daniele Valeriani

Split sidekiq and move the module to shared

parent a2b135b7
......@@ -166,6 +166,14 @@ module "subnet-registry" {
vnet_resource_group = "${module.vnet.resource_group_name}"
}
module "subnet-api-internal" {
source = "subnets/api-internal"
location = "${var.location}"
subnet_cidr = "10.132.12.0/23"
vnet_name = "${module.vnet.name}"
vnet_resource_group = "${module.vnet.resource_group_name}"
}
module "subnet-storage" {
source = "subnets/storage"
location = "${var.location}"
......@@ -195,7 +203,7 @@ module "virtual-machines-internal-lb" {
resource_group_name = "${module.subnet-internal-lb.resource_group_name}"
subnet_id = "${module.subnet-internal-lb.subnet_id}"
instance_type = "Standard_A1_v2"
tier = "sv"
tier = "lb"
environment = "${var.environment}"
address_prefix = "${module.subnet-internal-lb.address_prefix}"
first_user_username = "${var.first_user_username}"
......@@ -267,17 +275,24 @@ module "virtual-machines-git" {
}
module "virtual-machines-sidekiq" {
sidekiq_realtime_count = 1
sidekiq_besteffort_count = 1
source = "virtual-machines/sidekiq"
location = "${var.location}"
resource_group_name = "${module.subnet-sidekiq.resource_group_name}"
subnet_id = "${module.subnet-sidekiq.subnet_id}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
chef_repo_dir = "${var.chef_repo_dir}"
chef_vaults = "syslog-client gitlab-staging-base"
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
sidekiq_asap_count = 1
sidekiq_asap_instance_type = "Standard_D3_v2"
sidekiq_realtime_count = 1
sidekiq_realtime_instance_type = "Standard_F8"
sidekiq_besteffort_count = 1
sidekiq_besteffort_instance_type = "Standard_A4_v2"
source = "../../modules/virtual-machines/sidekiq"
resource_group_name = "${module.subnet-sidekiq.resource_group_name}"
subnet_id = "${module.subnet-sidekiq.subnet_id}"
tier = "sv"
environment = "${var.environment}"
address_prefix = "${module.subnet-sidekiq.address_prefix}"
location = "${var.location}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
chef_repo_dir = "${var.chef_repo_dir}"
chef_vaults = "syslog-client gitlab-staging-base"
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
}
module "virtual-machines-web" {
......@@ -308,3 +323,20 @@ module "virtual-machines-registry" {
chef_vaults = "syslog-client gitlab-staging-base"
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
}
module "virtual-machines-api-internal" {
count = 1
source = "../../modules/virtual-machines/api-internal"
resource_group_name = "${module.subnet-api-internal.resource_group_name}"
subnet_id = "${module.subnet-api-internal.subnet_id}"
instance_type = "Standard_A2_v2"
tier = "sv"
environment = "${var.environment}"
address_prefix = "${module.subnet-api-internal.address_prefix}"
location = "${var.location}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
chef_repo_dir = "${var.chef_repo_dir}"
chef_vaults = "syslog-client gitlab-staging-base"
gitlab_com_zone_id = "${var.gitlab_com_zone_id}"
}
variable "location" {}
variable "vnet_name" {}
variable "vnet_resource_group" {}
variable "subnet_cidr" {}
resource "azurerm_resource_group" "ApiInternalStaging" {
name = "ApiInternalStaging"
location = "${var.location}"
}
resource "azurerm_network_security_group" "ApiInternalStaging" {
name = "ApiInternalStaging"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.ApiInternalStaging.name}"
}
resource "azurerm_network_security_rule" "https" {
name = "https"
priority = 145
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
source_address_prefix = "10.128.0.0/12"
destination_port_range = "443"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.ApiInternalStaging.name}"
network_security_group_name = "${azurerm_network_security_group.ApiInternalStaging.name}"
}
resource "azurerm_network_security_rule" "ssh-from-vpn" {
name = "ssh-from-vpn"
priority = 149
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
source_address_prefix = "10.254.4.0/23"
destination_port_range = "22"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.ApiInternalStaging.name}"
network_security_group_name = "${azurerm_network_security_group.ApiInternalStaging.name}"
}
resource "azurerm_network_security_rule" "prometheus" {
name = "prometheus"
priority = 151
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
source_address_prefix = "10.4.1.0/24"
destination_port_range = "9100"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.ApiInternalStaging.name}"
network_security_group_name = "${azurerm_network_security_group.ApiInternalStaging.name}"
}
resource "azurerm_network_security_rule" "prometheus-gitaly" {
name = "prometheus-gitaly"
priority = 153
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
source_address_prefix = "10.4.1.0/24"
destination_port_range = "9236"
destination_address_prefix = "*"
resource_group_name = "${azurerm_resource_group.ApiInternalStaging.name}"
network_security_group_name = "${azurerm_network_security_group.ApiInternalStaging.name}"
}
resource "azurerm_subnet" "ApiInternalStaging" {
name = "ApiInternalStaging"
resource_group_name = "${var.vnet_resource_group}"
virtual_network_name = "${var.vnet_name}"
address_prefix = "${var.subnet_cidr}"
network_security_group_id = "${azurerm_network_security_group.ApiInternalStaging.id}"
}
output "subnet_id" {
value = "${azurerm_subnet.ApiInternalStaging.id}"
}
output "address_prefix" {
value = "${azurerm_subnet.ApiInternalStaging.address_prefix}"
}
output "resource_group_name" {
value = "ApiInternalStaging"
}
output "resource_group_id" {
value = "${azurerm_resource_group.ApiInternalStaging.id}"
}
......@@ -3,3 +3,4 @@
but just in case we run a terraform command
here we want to do nothing
*/
resource "azurerm_availability_set" "SidekiqStaging" {
name = "SidekiqStaging"
resource "azurerm_availability_set" "api-internal" {
name = "${format("api-internal-%v", var.environment)}"
location = "${var.location}"
managed = true
platform_update_domain_count = 20
......@@ -7,43 +7,37 @@ resource "azurerm_availability_set" "SidekiqStaging" {
resource_group_name = "${var.resource_group_name}"
}
resource "azurerm_public_ip" "sidekiq01" {
name = "sidekiq01-stg-public-ip"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "static"
domain_name_label = "sidekiq01-stg"
}
resource "azurerm_network_interface" "sidekiq01" {
name = "sidekiq01-stg"
internal_dns_name_label = "sidekiq01-stg"
resource "azurerm_network_interface" "api-internal" {
count = "${var.count}"
name = "${format("api-internal%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("api-internal%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
ip_configuration {
name = "sidekiq01-stg-ip-configuration"
name = "${format("api-internal%02d-%v", count.index + 1, var.environment)}"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "static"
private_ip_address = "10.132.6.101"
public_ip_address_id = "${azurerm_public_ip.sidekiq01.id}"
private_ip_address = "${join(".", slice(split(".", var.address_prefix), 0, 3))}.${count.index + 101}"
}
}
resource "aws_route53_record" "sidekiq01" {
resource "aws_route53_record" "api-internal" {
count = "${var.count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "sidekiq01.stg.gitlab.com"
type = "CNAME"
name = "${format("api-internal%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
type = "A"
ttl = "300"
records = ["${azurerm_public_ip.sidekiq01.fqdn}"]
records = ["${azurerm_network_interface.api-internal.*.private_ip_address[count.index]}"]
}
data "template_file" "chef-bootstrap-sidekiq01" {
data "template_file" "chef-bootstrap-api-internal" {
count = "${var.count}"
template = "${file("${path.root}/templates/chef-bootstrap.tpl")}"
vars {
ip_address = "${azurerm_public_ip.sidekiq01.ip_address}"
hostname = "sidekiq01.stg.gitlab.com"
ip_address = "${azurerm_network_interface.api-internal.*.private_ip_address[count.index]}"
hostname = "${format("api-internal%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
chef_repo_dir = "${var.chef_repo_dir}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
......@@ -51,13 +45,15 @@ data "template_file" "chef-bootstrap-sidekiq01" {
}
}
resource "azurerm_virtual_machine" "sidekiq01" {
name = "sidekiq01.stg.gitlab.com"
resource "azurerm_virtual_machine" "api-internal" {
count = "${var.count}"
name = "${format("api-internal%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${azurerm_availability_set.SidekiqStaging.id}"
network_interface_ids = ["${azurerm_network_interface.sidekiq01.id}"]
vm_size = "Standard_F4s"
availability_set_id = "${azurerm_availability_set.api-internal.id}"
network_interface_ids = ["${azurerm_network_interface.api-internal.*.id[count.index]}"]
primary_network_interface_id = "${azurerm_network_interface.api-internal.*.id[count.index]}"
vm_size = "${var.instance_type}"
delete_os_disk_on_termination = true
storage_image_reference {
......@@ -68,20 +64,24 @@ resource "azurerm_virtual_machine" "sidekiq01" {
}
storage_os_disk {
name = "osdisk-sidekiq01-stg"
name = "${format("osdisk-api-internal%02d-%v", count.index + 1, var.environment)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "sidekiq01.stg.gitlab.com"
computer_name = "${format("api-internal%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
admin_username = "${var.first_user_username}"
admin_password = "${var.first_user_password}"
}
os_profile_linux_config {
disable_password_authentication = false
}
provisioner "local-exec" {
command = "${data.template_file.chef-bootstrap-sidekiq01.rendered}"
command = "${data.template_file.chef-bootstrap-api-internal.*.rendered[count.index]}"
}
provisioner "remote-exec" {
......@@ -89,14 +89,10 @@ resource "azurerm_virtual_machine" "sidekiq01" {
connection {
type = "ssh"
host = "${azurerm_public_ip.sidekiq01.ip_address}"
host = "${azurerm_network_interface.api-internal.*.private_ip_address[count.index]}"
user = "${var.first_user_username}"
password = "${var.first_user_password}"
timeout = "10s"
}
}
}
output "availability_set_id" {
value = "${azurerm_availability_set.SidekiqStaging.id}"
}
variable "location" {}
variable "resource_group_name" {}
variable "subnet_id" {}
variable "first_user_username" {}
variable "first_user_password" {}
variable "address_prefix" {}
variable "chef_repo_dir" {}
variable "chef_vaults" {}
variable "count" {}
variable "environment" {}
variable "first_user_password" {}
variable "first_user_username" {}
variable "gitlab_com_zone_id" {}
variable "sidekiq_realtime_count" {}
variable "sidekiq_besteffort_count" {}
variable "instance_type" {}
variable "location" {}
variable "resource_group_name" {}
variable "subnet_id" {}
variable "tier" {}
......@@ -9,13 +9,13 @@ resource "azurerm_availability_set" "backend-lb" {
resource "azurerm_network_interface" "backend-lb" {
count = "${var.backend_lb_count}"
name = "${format("backend-lb%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("backend-lb%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
name = "${format("backend%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("backend%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
ip_configuration {
name = "${format("backend-lb%02d-%v", count.index + 1, var.environment)}"
name = "${format("backend%02d-%v", count.index + 1, var.environment)}"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "static"
private_ip_address = "${join(".", slice(split(".", var.address_prefix), 0, 3))}.${count.index + 101}"
......@@ -25,7 +25,7 @@ resource "azurerm_network_interface" "backend-lb" {
resource "aws_route53_record" "backend-lb" {
count = "${var.backend_lb_count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "${format("backend-lb%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
name = "${format("backend%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
type = "A"
ttl = "300"
records = ["${azurerm_network_interface.backend-lb.*.private_ip_address[count.index]}"]
......@@ -37,7 +37,7 @@ data "template_file" "chef-bootstrap-backend-lb" {
vars {
ip_address = "${azurerm_network_interface.backend-lb.*.private_ip_address[count.index]}"
hostname = "${format("backend-lb%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
hostname = "${format("backend%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
chef_repo_dir = "${var.chef_repo_dir}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
......@@ -47,7 +47,7 @@ data "template_file" "chef-bootstrap-backend-lb" {
resource "azurerm_virtual_machine" "backend-lb" {
count = "${var.backend_lb_count}"
name = "${format("backend-lb%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
name = "${format("backend%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${azurerm_availability_set.backend-lb.id}"
......@@ -64,14 +64,14 @@ resource "azurerm_virtual_machine" "backend-lb" {
}
storage_os_disk {
name = "${format("osdisk-backend-lb%02d-%v", count.index + 1, var.environment)}"
name = "${format("osdisk-backend%02d-%v", count.index + 1, var.environment)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "${format("backend-lb%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
computer_name = "${format("backend%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
admin_username = "${var.first_user_username}"
admin_password = "${var.first_user_password}"
}
......
......@@ -12,7 +12,6 @@ variable "gitlab_com_zone_id" {}
variable "address_prefix" {}
variable "instance_type" {}
resource "azurerm_availability_set" "registry" {
name = "${format("registry-%v", var.environment)}"
location = "${var.location}"
......
resource "azurerm_availability_set" "sidekiq-asap" {
name = "${format("sidekiq-asap-%v", var.environment)}"
location = "${var.location}"
managed = true
platform_update_domain_count = 20
platform_fault_domain_count = 3
resource_group_name = "${var.resource_group_name}"
}
resource "azurerm_network_interface" "sidekiq-asap" {
count = "${var.sidekiq_asap_count}"
name = "${format("sidekiq-asap%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("sidekiq-asap%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
ip_configuration {
name = "${format("sidekiq-asap%02d-%v", count.index + 1, var.environment)}"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "static"
private_ip_address = "${join(".", slice(split(".", var.address_prefix), 0, 3))}.${count.index + 101}"
}
}
resource "aws_route53_record" "sidekiq-asap" {
count = "${var.sidekiq_asap_count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "${format("sidekiq-asap%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
type = "A"
ttl = "300"
records = ["${azurerm_network_interface.sidekiq-asap.*.private_ip_address[count.index]}"]
}
data "template_file" "chef-bootstrap-sidekiq-asap" {
count = "${var.sidekiq_asap_count}"
template = "${file("${path.root}/templates/chef-bootstrap.tpl")}"
vars {
ip_address = "${azurerm_network_interface.sidekiq-asap.*.private_ip_address[count.index]}"
hostname = "${format("sidekiq-asap%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
chef_repo_dir = "${var.chef_repo_dir}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
chef_vaults = "${var.chef_vaults}"
}
}
resource "azurerm_virtual_machine" "sidekiq-asap" {
count = "${var.sidekiq_asap_count}"
name = "${format("sidekiq-asap%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${azurerm_availability_set.sidekiq-asap.id}"
network_interface_ids = ["${azurerm_network_interface.sidekiq-asap.*.id[count.index]}"]
primary_network_interface_id = "${azurerm_network_interface.sidekiq-asap.*.id[count.index]}"
vm_size = "${var.sidekiq_asap_instance_type}"
delete_os_disk_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "${format("osdisk-sidekiq-asap%02d-%v", count.index + 1, var.environment)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "${format("sidekiq-asap%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
admin_username = "${var.first_user_username}"
admin_password = "${var.first_user_password}"
}
os_profile_linux_config {
disable_password_authentication = false
}
provisioner "local-exec" {
command = "${data.template_file.chef-bootstrap-sidekiq-asap.*.rendered[count.index]}"
}
provisioner "remote-exec" {
inline = ["nohup bash -c 'sudo chef-client &'"]
connection {
type = "ssh"
host = "${azurerm_network_interface.sidekiq-asap.*.private_ip_address[count.index]}"
user = "${var.first_user_username}"
password = "${var.first_user_password}"
timeout = "10s"
}
}
}
resource "azurerm_availability_set" "SidekiqBesteffortStaging" {
name = "SidekiqBesteffortStaging"
resource "azurerm_availability_set" "sidekiq-besteffort" {
name = "${format("sidekiq-besteffort-%v", var.environment)}"
location = "${var.location}"
managed = true
platform_update_domain_count = 20
......@@ -7,38 +7,28 @@ resource "azurerm_availability_set" "SidekiqBesteffortStaging" {
resource_group_name = "${var.resource_group_name}"
}
resource "azurerm_public_ip" "sidekiq-besteffort" {
count = "${var.sidekiq_besteffort_count}"
name = "${format("sidekiq-besteffort%02d-stg-public-ip", count.index + 1)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "static"
domain_name_label = "${format("sidekiq-besteffort%02d-stg", count.index + 1)}"
}
resource "azurerm_network_interface" "sidekiq-besteffort" {
count = "${var.sidekiq_besteffort_count}"
name = "${format("sidekiq-besteffort%02d-stg", count.index + 1)}"
internal_dns_name_label = "${format("sidekiq-besteffort%02d-stg", count.index + 1)}"
name = "${format("sidekiq-besteffort%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("sidekiq-besteffort%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
ip_configuration {
name = "${format("sidekiq-besteffort%02d-stg", count.index + 1)}"
name = "${format("sidekiq-besteffort%02d-%v", count.index + 1, var.environment)}"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "static"
private_ip_address = "10.132.6.${format("%02d", count.index + 151)}"
public_ip_address_id = "${azurerm_public_ip.sidekiq-besteffort.*.id[count.index]}"
private_ip_address = "${join(".", slice(split(".", var.address_prefix), 0, 3))}.${count.index + 151}"
}
}
resource "aws_route53_record" "sidekiq-besteffort" {
count = "${var.sidekiq_besteffort_count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "${format("sidekiq-besteffort%02d.stg.gitlab.com.", count.index + 1)}"
type = "CNAME"
name = "${format("sidekiq-besteffort%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
type = "A"
ttl = "300"
records = ["${azurerm_public_ip.sidekiq-besteffort.*.fqdn[count.index]}"]
records = ["${azurerm_network_interface.sidekiq-besteffort.*.private_ip_address[count.index]}"]
}
data "template_file" "chef-bootstrap-sidekiq-besteffort" {
......@@ -46,8 +36,8 @@ data "template_file" "chef-bootstrap-sidekiq-besteffort" {
template = "${file("${path.root}/templates/chef-bootstrap.tpl")}"
vars {
ip_address = "${azurerm_public_ip.sidekiq-besteffort.*.ip_address[count.index]}"
hostname = "${format("sidekiq-besteffort%02d.stg.gitlab.com", count.index + 1)}"
ip_address = "${azurerm_network_interface.sidekiq-besteffort.*.private_ip_address[count.index]}"
hostname = "${format("sidekiq-besteffort%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
chef_repo_dir = "${var.chef_repo_dir}"
first_user_username = "${var.first_user_username}"
first_user_password = "${var.first_user_password}"
......@@ -57,13 +47,13 @@ data "template_file" "chef-bootstrap-sidekiq-besteffort" {
resource "azurerm_virtual_machine" "sidekiq-besteffort" {
count = "${var.sidekiq_besteffort_count}"
name = "${format("sidekiq-besteffort%02d.stg.gitlab.com", count.index + 1)}"
name = "${format("sidekiq-besteffort%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
availability_set_id = "${azurerm_availability_set.SidekiqBesteffortStaging.id}"
availability_set_id = "${azurerm_availability_set.sidekiq-besteffort.id}"
network_interface_ids = ["${azurerm_network_interface.sidekiq-besteffort.*.id[count.index]}"]
primary_network_interface_id = "${azurerm_network_interface.sidekiq-besteffort.*.id[count.index]}"
vm_size = "Standard_A4m_v2"
vm_size = "${var.sidekiq_besteffort_instance_type}"
delete_os_disk_on_termination = true
storage_image_reference {
......@@ -74,14 +64,14 @@ resource "azurerm_virtual_machine" "sidekiq-besteffort" {
}
storage_os_disk {
name = "${format("osdisk-sidekiq-besteffort%02d", count.index + 1)}"
name = "${format("osdisk-sidekiq-besteffort%02d-%v", count.index + 1, var.environment)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "${format("sidekiq-besteffort%02d.stg.gitlab.com", count.index + 1)}"
computer_name = "${format("sidekiq-besteffort%02d.%v.%v.gitlab.com", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
admin_username = "${var.first_user_username}"
admin_password = "${var.first_user_password}"
}
......@@ -99,7 +89,7 @@ resource "azurerm_virtual_machine" "sidekiq-besteffort" {
connection {
type = "ssh"
host = "${azurerm_public_ip.sidekiq-besteffort.*.ip_address[count.index]}"
host = "${azurerm_network_interface.sidekiq-besteffort.*.private_ip_address[count.index]}"
user = "${var.first_user_username}"
password = "${var.first_user_password}"
timeout = "10s"
......
resource "azurerm_availability_set" "SidekiqRealtimeStaging" {
name = "SidekiqRealtimeStaging"
resource "azurerm_availability_set" "sidekiq-realtime" {
name = "${format("sidekiq-realtime-%v", var.environment)}"
location = "${var.location}"
managed = true
platform_update_domain_count = 20
......@@ -7,38 +7,28 @@ resource "azurerm_availability_set" "SidekiqRealtimeStaging" {
resource_group_name = "${var.resource_group_name}"
}
resource "azurerm_public_ip" "sidekiq-realtime" {
count = "${var.sidekiq_realtime_count}"
name = "${format("sidekiq-realtime%02d-stg-public-ip", count.index + 1)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
public_ip_address_allocation = "static"
domain_name_label = "${format("sidekiq-realtime%02d-stg", count.index + 1)}"
}
resource "azurerm_network_interface" "sidekiq-realtime" {
count = "${var.sidekiq_realtime_count}"
name = "${format("sidekiq-realtime%02d-stg", count.index + 1)}"
internal_dns_name_label = "${format("sidekiq-realtime%02d-stg", count.index + 1)}"
name = "${format("sidekiq-realtime%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
internal_dns_name_label = "${format("sidekiq-realtime%02d-%v-%v", count.index + 1, var.tier, var.environment)}"
location = "${var.location}"
resource_group_name = "${var.resource_group_name}"
ip_configuration {
name = "${format("sidekiq-realtime%02d-stg", count.index + 1)}"
name = "${format("sidekiq-realtime%02d-%v", count.index + 1, var.environment)}"
subnet_id = "${var.subnet_id}"
private_ip_address_allocation = "static"
private_ip_address = "10.132.6.${format("%02d", count.index + 51)}"
public_ip_address_id = "${azurerm_public_ip.sidekiq-realtime.*.id[count.index]}"
private_ip_address = "${join(".", slice(split(".", var.address_prefix), 0, 3))}.${count.index + 201}"
}
}
resource "aws_route53_record" "sidekiq-realtime" {
count = "${var.sidekiq_realtime_count}"
zone_id = "${var.gitlab_com_zone_id}"
name = "${format("sidekiq-realtime%02d.stg.gitlab.com.", count.index + 1)}"
type = "CNAME"
name = "${format("sidekiq-realtime%02d.%v.%v.gitlab.com.", count.index + 1, var.tier, var.environment == "prod" ? "prd" : var.environment)}"
type = "A"
ttl = "300"
records = ["${azurerm_public_ip.sidekiq-realtime.*.fqdn[count.index]}"]
records = ["${azurerm_network_interface.sidekiq-realtime.*.private_ip_address[count.index]}"]
}
data "template_file" "chef-bootstrap-sidekiq-realtime" {
......@@ -46,8 +36,8 @@ data "template_file" "chef-bootstrap-sidekiq-realtime" {
template