Skip to content

Commit

Permalink
Merge pull request #1 from Azure-Terraform/address_prefixes
Browse files Browse the repository at this point in the history
Address prefixes
  • Loading branch information
dutsmiller authored May 29, 2020
2 parents f3f81a2 + af64abc commit 28dc74c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 23 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@ service-market-environment-location-product
| Name | Version |
|------|---------|
| azurerm | >= 2.0.0 |
| http | >= 1.2.0 |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:-----:|
| address\_space | CIDRs for virtual network | `list` | n/a | yes |
| address\_space | CIDRs for virtual network | `list(string)` | n/a | yes |
| location | Azure Region | `string` | n/a | yes |
| names | Names to be applied to resources | `map(string)` | n/a | yes |
| naming\_conventions\_yaml\_url | URL for naming conventions yaml file | `string` | `"https://raw.githubusercontent.com/openrba/python-azure-naming/master/custom.yaml"` | no |
| naming\_rules | naming conventions yaml file | `string` | n/a | yes |
| resource\_group\_name | Resource group name | `string` | n/a | yes |
| subnets | Subnet types and CIDRs. format: { [0-9][0-9]-<subnet\_type> = cidr }) (increment from 01, cannot be reordered) | `map(string)` | `{}` | no |
| subnets | Subnet types and lists of CIDRs. format: { [0-9][0-9]-<subnet\_type> = cidr }) (increment from 01, cannot be reordered) | `map(list(string))` | `{}` | no |
| tags | Tags to be applied to resources | `map(string)` | n/a | yes |

## Outputs
Expand Down
12 changes: 2 additions & 10 deletions data_sources.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
data "http" "naming_rules" {
url = var.naming_conventions_yaml_url

request_headers = {
Accept = "application/yaml"
}
}

locals {
naming_rules = yamldecode(data.http.naming_rules.body)
naming_rules = yamldecode(var.naming_rules)
subnet_types = local.naming_rules.subnetType.allowed_values

valid_subnet_input = [
Expand All @@ -19,4 +11,4 @@ locals {
for subnet in keys(var.subnets):
(contains(keys(local.subnet_types), substr(subnet, 3, -1)) ? null : file("ERROR: invalid input value for reserved subnet type"))
]
}
}
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resource "azurerm_subnet" "subnet" {
name = "${substr(keys(var.subnets)[count.index], 3, -1)}-subnet"
resource_group_name = var.resource_group_name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefix = values(var.subnets)[count.index]
address_prefixes = values(var.subnets)[count.index]
}

resource "azurerm_subnet_network_security_group_association" "subnet_nsg" {
Expand Down Expand Up @@ -56,4 +56,4 @@ resource "azurerm_network_security_rule" "deny_all_outbound" {
destination_address_prefix = "*"
resource_group_name = var.resource_group_name
network_security_group_name = azurerm_network_security_group.nsg.*.name[count.index]
}
}
13 changes: 6 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
variable "naming_conventions_yaml_url" {
description = "URL for naming conventions yaml file"
variable "naming_rules" {
description = "naming conventions yaml file"
type = string
default = "https://raw.githubusercontent.com/openrba/python-azure-naming/master/custom.yaml"
}

variable "resource_group_name"{
Expand All @@ -25,13 +24,13 @@ variable "tags" {
}

# Networking
variable "address_space"{
variable "address_space" {
description = "CIDRs for virtual network"
type = list
type = list(string)
}

variable "subnets" {
description = "Subnet types and CIDRs. format: { [0-9][0-9]-<subnet_type> = cidr }) (increment from 01, cannot be reordered)"
type = map(string)
description = "Subnet types and lists of CIDRs. format: { [0-9][0-9]-<subnet_type> = cidr }) (increment from 01, cannot be reordered)"
type = map(list(string))
default = {}
}

0 comments on commit 28dc74c

Please sign in to comment.