Skip to content

Commit

Permalink
[azure][vnet] pass AZ as variable, rename nat gateways to include env (
Browse files Browse the repository at this point in the history
#39)

* updating vnet module to pass az as variable, rename nat gateways with environments

* pre-commit fix

* add optional prefix for nat

* nat_prefix default as empty string
  • Loading branch information
KoomeKiriinya committed Jul 19, 2024
1 parent b77e1b7 commit bbe7d77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 2 additions & 1 deletion modules/azure/networking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_environment"></a> [environment](#input\_environment) | Environment like: infra-ops, dev, stage, prod | `string` | n/a | yes |
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | Availability zones for nat gateway and public ips | `list(string)` | n/a | yes |
| <a name="input_nat_prefix"></a> [nat\_prefix](#input\_nat\_prefix) | Prefix of the nat gateway & public ip address | `string` | `""` | no |
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Azure resource group name | `string` | n/a | yes |
| <a name="input_subnets"></a> [subnets](#input\_subnets) | Azure subnets and their configuration | <pre>map(object({<br> address_prefixes = list(string)<br> enable_nat = bool<br> service_endpoints = list(string)<br> private_endpoint_network_policies = string # Allowed values: "Disabled", "Enabled", "NetworkSecurityGroupEnabled" and "RouteTableEnabled"<br> delegations = map(object({<br> service_delegation_name = string<br> service_delegation_actions = list(string)<br> }))<br> security_rules = optional(map(object({<br> priority = number<br> direction = string<br> access = string<br> protocol = string<br> source_port_range = optional(string)<br> source_port_ranges = optional(list(string))<br> destination_port_range = optional(string)<br> destination_port_ranges = optional(list(string))<br> source_address_prefix = optional(string)<br> source_address_prefixes = optional(list(string))<br> destination_address_prefix = optional(string)<br> destination_address_prefixes = optional(list(string))<br> source_application_security_group_ids = optional(list(string))<br> })), {})<br> routes = optional(map(object({<br> address_prefix = string<br> next_hop_type = string<br> next_hop_in_ip_address = optional(string)<br> })))<br> }))</pre> | n/a | yes |
| <a name="input_vnet_address_space"></a> [vnet\_address\_space](#input\_vnet\_address\_space) | Address space for the virtual network | `list(string)` | n/a | yes |
Expand Down
8 changes: 4 additions & 4 deletions modules/azure/networking/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ resource "azurerm_subnet" "subnets" {

resource "azurerm_public_ip" "nat_address" {
count = 2
name = "nat-external-address-${count.index}"
name = "${var.nat_prefix}-nat-external-address-${count.index}"
location = var.vnet_location
resource_group_name = var.resource_group_name
allocation_method = "Static"
sku = "Standard"
zones = ["1"]
zones = var.availability_zones
}

resource "azurerm_nat_gateway" "nat_gateway" {
name = "${var.environment}-nat-gateway"
name = "${var.nat_prefix}-nat-gateway"
location = var.vnet_location
resource_group_name = var.resource_group_name
sku_name = "Standard"
idle_timeout_in_minutes = 10
zones = ["1"]
zones = var.availability_zones
}

resource "azurerm_nat_gateway_public_ip_association" "nat_address_gateway_association" {
Expand Down
16 changes: 11 additions & 5 deletions modules/azure/networking/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "environment" {
description = "Environment like: infra-ops, dev, stage, prod"
type = string
}

variable "resource_group_name" {
description = "Azure resource group name"
type = string
Expand All @@ -18,11 +13,22 @@ variable "vnet_location" {
type = string
}

variable "availability_zones" {
description = "Availability zones for nat gateway and public ips"
type = list(string)
}

variable "vnet_address_space" {
description = "Address space for the virtual network"
type = list(string)
}

variable "nat_prefix" {
description = "Prefix of the nat gateway & public ip address"
type = string
default = ""

}
variable "subnets" {
description = "Azure subnets and their configuration"
type = map(object({
Expand Down

0 comments on commit bbe7d77

Please sign in to comment.