Skip to content
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

[azure][vnet] pass AZ as variable, rename nat gateways to include env #39

Merged
merged 4 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading