Skip to content

Commit 59862c6

Browse files
authored
azure: expose vnet_cidr parameter in main module (#188)
1 parent 2142364 commit 59862c6

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

azure/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ terraform apply -var="datadog-api-key=$DD_API_KEY"
107107
| <a name="input_scanner_version"></a> [scanner\_version](#input\_scanner\_version) | Version of the scanner to install | `string` | `"0.11"` | no |
108108
| <a name="input_site"></a> [site](#input\_site) | By default the Agent sends its data to Datadog US site. If your organization is on another site, you must update it. See https://docs.datadoghq.com/getting_started/site/ | `string` | `null` | no |
109109
| <a name="input_tags"></a> [tags](#input\_tags) | A map of additional tags to add to the resources created. | `map(string)` | `{}` | no |
110+
| <a name="input_vnet_cidr"></a> [vnet\_cidr](#input\_vnet\_cidr) | The CIDR block for the Virtual Network | `string` | `"10.0.0.0/16"` | no |
110111

111112
## Outputs
112113

azure/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module "virtual_network" {
3333
source = "./modules/virtual-network"
3434
resource_group_name = module.resource_group.resource_group.name
3535
location = var.location
36+
cidr = var.vnet_cidr
3637
bastion = var.bastion
3738
tags = var.tags
3839
}

azure/modules/virtual-network/main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,32 @@ resource "azurerm_subnet_nat_gateway_association" "subnet_natgw_assoc" {
5151

5252
# Bastion (optional)
5353
resource "azurerm_bastion_host" "bastion" {
54-
count = var.bastion == true ? 1 : 0
54+
count = var.bastion ? 1 : 0
5555

5656
name = "bastion"
5757
location = azurerm_virtual_network.vnet.location
5858
resource_group_name = azurerm_virtual_network.vnet.resource_group_name
5959
ip_configuration {
6060
name = "ipconfig"
61-
subnet_id = azurerm_subnet.bastion_subnet.id
62-
public_ip_address_id = azurerm_public_ip.bastion_ip[count.index].id
61+
subnet_id = one(azurerm_subnet.bastion_subnet).id
62+
public_ip_address_id = one(azurerm_public_ip.bastion_ip).id
6363
}
6464
sku = "Standard"
6565
tunneling_enabled = true
6666
tags = merge(var.tags, local.dd_tags)
6767
}
6868

6969
resource "azurerm_subnet" "bastion_subnet" {
70+
count = var.bastion ? 1 : 0
71+
7072
name = "AzureBastionSubnet"
7173
resource_group_name = azurerm_virtual_network.vnet.resource_group_name
7274
virtual_network_name = azurerm_virtual_network.vnet.name
7375
address_prefixes = [cidrsubnet(var.cidr, 2, 1)]
7476
}
7577

7678
resource "azurerm_public_ip" "bastion_ip" {
77-
count = var.bastion == true ? 1 : 0
79+
count = var.bastion ? 1 : 0
7880

7981
name = "bastion-ip"
8082
location = azurerm_virtual_network.vnet.location

azure/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ variable "scan_scopes" {
4848
default = []
4949
}
5050

51+
variable "vnet_cidr" {
52+
description = "The CIDR block for the Virtual Network"
53+
type = string
54+
default = "10.0.0.0/16"
55+
}
56+
5157
variable "bastion" {
5258
description = "Create a bastion in the subnet."
5359
type = bool

0 commit comments

Comments
 (0)