-
Notifications
You must be signed in to change notification settings - Fork 11
Cpapke/update azure poc #471
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,22 +1,26 @@ | ||
| # locals { | ||
| # hub_subnet_id = var.subnet_ids != null ? var.subnet_ids.hub_subnet_id : module.vpc[0].public_subnets[0] | ||
| # hub_dr_subnet_id = var.subnet_ids != null ? var.subnet_ids.hub_dr_subnet_id : module.vpc[0].public_subnets[1] | ||
| # agentless_gw_subnet_id = var.subnet_ids != null ? var.subnet_ids.agentless_gw_subnet_id : module.vpc[0].private_subnets[0] | ||
| # agentless_gw_dr_subnet_id = var.subnet_ids != null ? var.subnet_ids.agentless_gw_dr_subnet_id : module.vpc[0].private_subnets[1] | ||
| # db_subnet_ids = var.subnet_ids != null ? var.subnet_ids.db_subnet_ids : module.vpc[0].public_subnets | ||
| # mx_subnet_id = var.subnet_ids != null ? var.subnet_ids.mx_subnet_id : module.vpc[0].public_subnets[0] | ||
| # dra_admin_subnet_id = var.subnet_ids != null ? var.subnet_ids.dra_admin_subnet_id : module.vpc[0].public_subnets[0] | ||
| # dra_analytics_subnet_id = var.subnet_ids != null ? var.subnet_ids.dra_analytics_subnet_id : module.vpc[0].private_subnets[0] | ||
| # agent_gw_subnet_id = var.subnet_ids != null ? var.subnet_ids.agent_gw_subnet_id : module.vpc[0].private_subnets[0] | ||
| # } | ||
|
|
||
| locals { | ||
| create_network = var.subnet_ids == null && var.subnet_id == null | ||
|
|
||
| hub_subnet_id = coalesce(try(var.subnet_ids.hub_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[0]) | ||
| hub_dr_subnet_id = coalesce(try(var.subnet_ids.hub_dr_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[1]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vnet_subnets[0]
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what it was already, if you are looking for changes to the existing behaviour, that should be done separately.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understood correctly, there is no existing behavior, the commented out bulk of local variables is a copy & paste from the AWS example, which is incorrect in the Azure case due to different private and public subnet modeling
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what you mean. Previously, the |
||
|
|
||
| agentless_gw_subnet_id = coalesce(try(var.subnet_ids.agentless_gw_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[0]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vnet_subnets[1]
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
| agentless_gw_dr_subnet_id = coalesce(try(var.subnet_ids.agentless_gw_dr_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[1]) | ||
|
|
||
| db_subnet_ids = coalescelist(try(var.subnet_ids.db_subnet_ids, []), compact([var.subnet_id]), module.network[0].vnet_subnets) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only vnet_subnets[1]
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
|
||
| mx_subnet_id = coalesce(try(var.subnet_ids.mx_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[0]) | ||
| agent_gw_subnet_id = coalesce(try(var.subnet_ids.agent_gw_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[0]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vnet_subnets[1]
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
|
|
||
| dra_admin_subnet_id = coalesce(try(var.subnet_ids.dra_admin_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[0]) | ||
| dra_analytics_subnet_id = coalesce(try(var.subnet_ids.dra_analytics_subnet_id, null), var.subnet_id, module.network[0].vnet_subnets[1]) | ||
|
|
||
| subnet_prefixes = cidrsubnets(var.vnet_ip_range, 8, 8) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that this generates two subnet ranges: "10.0.0.0/24" and "10.0.1.0/24". This is different from the AWS deployment. Here, the first one is public and the second is private, see comment at the bottom of the networking.tf file. The deployment we want - VMs with a public interface should be in the public subnet, all the rest in a private subnet. Meaning, Hub main, Hub DR, MX, DRA Admin and DBs - in the public subnet. Agentless GWs main, Agentless GWs DR, Agent GW, DRA Analytics - in the private subnet.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I did in this PR keeps everything the same if the subnet_ids aren't passed in. If you want to change how the network module works, that shouldn't be done in this PR, as these are meant to get our tests working, and don't change the default case. |
||
| } | ||
|
|
||
| # network | ||
| module "network" { | ||
| count = 1 | ||
| count = local.create_network ? 1 : 0 | ||
| source = "Azure/network/azurerm" | ||
| version = "5.3.0" | ||
| vnet_name = "${local.deployment_name_salted}-${module.globals.current_user_name}" | ||
|
|
@@ -32,41 +36,8 @@ module "network" { | |
| ] | ||
| } | ||
|
|
||
| # data "aws_subnet" "hub" { | ||
| # id = local.hub_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "hub_dr" { | ||
| # id = local.hub_dr_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "agentless_gw" { | ||
| # id = local.agentless_gw_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "agentless_gw_dr" { | ||
| # id = local.agentless_gw_dr_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "mx" { | ||
| # id = local.mx_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "agent_gw" { | ||
| # id = local.agent_gw_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "dra_admin" { | ||
| # id = local.dra_admin_subnet_id | ||
| # } | ||
|
|
||
| # data "aws_subnet" "dra_analytics" { | ||
| # id = local.dra_analytics_subnet_id | ||
| # } | ||
|
|
||
| # NAT | ||
|
|
||
| resource "azurerm_public_ip" "nat_gw_public_ip" { | ||
| count = local.create_network ? 1 : 0 | ||
| name = join("-", [var.deployment_name, "nat", "public", "ip"]) | ||
| location = local.resource_group.location | ||
| resource_group_name = local.resource_group.name | ||
|
|
@@ -75,6 +46,7 @@ resource "azurerm_public_ip" "nat_gw_public_ip" { | |
| } | ||
|
|
||
| resource "azurerm_nat_gateway" "nat_gw" { | ||
| count = local.create_network ? 1 : 0 | ||
| name = join("-", [var.deployment_name, "nat", "gw"]) | ||
| location = local.resource_group.location | ||
| resource_group_name = local.resource_group.name | ||
|
|
@@ -83,12 +55,14 @@ resource "azurerm_nat_gateway" "nat_gw" { | |
| } | ||
|
|
||
| resource "azurerm_nat_gateway_public_ip_association" "nat_gw_public_ip_association" { | ||
| nat_gateway_id = azurerm_nat_gateway.nat_gw.id | ||
| public_ip_address_id = azurerm_public_ip.nat_gw_public_ip.id | ||
| count = local.create_network ? 1 : 0 | ||
| nat_gateway_id = azurerm_nat_gateway.nat_gw[0].id | ||
| public_ip_address_id = azurerm_public_ip.nat_gw_public_ip[0].id | ||
| } | ||
|
|
||
| # subnet 1 is the private subnet | ||
| resource "azurerm_subnet_nat_gateway_association" "nat_gw_vnet_association" { | ||
| count = local.create_network ? 1 : 0 | ||
| subnet_id = module.network[0].vnet_subnets[1] | ||
| nat_gateway_id = azurerm_nat_gateway.nat_gw.id | ||
| nat_gateway_id = azurerm_nat_gateway.nat_gw[0].id | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this solution of adding subnet_id variable, the subnet_ids is cumbersome when you only want to provide one subnet. We should port it to the AWS dsf_deployment example sometime.