Skip to content

claranet/terraform-azurerm-nat-gateway

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure NAT Gateway

Changelog Notice Apache V2 License OpenTofu Registry

Common Azure terraform module to create a nat gateway and do the association with subnet(s).

Global versioning rule for Claranet Azure modules

Module version Terraform version OpenTofu version AzureRM version
>= 8.x.x Unverified 1.8.x >= 4.0
>= 7.x.x 1.3.x >= 3.0
>= 6.x.x 1.x >= 3.0
>= 5.x.x 0.15.x >= 2.0
>= 4.x.x 0.13.x / 0.14.x >= 2.0
>= 3.x.x 0.12.x >= 2.0
>= 2.x.x 0.12.x < 2.0
< 2.x.x 0.11.x < 2.0

Contributing

If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.

More details are available in the CONTRIBUTING.md file.

Usage

This module is optimized to work with the Claranet terraform-wrapper tool which set some terraform variables in the environment needed by this module. More details about variables set by the terraform-wrapper available in the documentation.

⚠️ Since modules version v8.0.0, we do not maintain/check anymore the compatibility with Hashicorp Terraform. Instead, we recommend to use OpenTofu.

module "azure_region" {
  source  = "claranet/regions/azurerm"
  version = "x.x.x"

  azure_region = var.azure_region
}

module "rg" {
  source  = "claranet/rg/azurerm"
  version = "x.x.x"

  location    = module.azure_region.location
  client_name = var.client_name
  environment = var.environment
  stack       = var.stack
}

module "azure_network_vnet" {
  source  = "claranet/vnet/azurerm"
  version = "x.x.x"

  environment         = var.environment
  location            = module.azure_region.location
  location_short      = module.azure_region.location_short
  client_name         = var.client_name
  stack               = var.stack
  resource_group_name = module.rg.resource_group_name

  vnet_cidr = ["10.0.1.0/24"]
}

module "azure_network_subnet" {
  source  = "claranet/subnet/azurerm"
  version = "x.x.x"

  environment         = var.environment
  location_short      = module.azure_region.location_short
  client_name         = var.client_name
  stack               = var.stack
  resource_group_name = module.rg.resource_group_name

  virtual_network_name = module.azure_network_vnet.virtual_network_name
  subnet_cidr_list     = ["10.0.1.0/26"]
}

module "nat_gateway" {
  source  = "claranet/nat-gateway/azurerm"
  version = "x.x.x"

  client_name         = var.client_name
  environment         = var.environment
  location            = module.azure_region.location
  location_short      = module.azure_region.location_short
  stack               = var.stack
  resource_group_name = module.rg.resource_group_name

  subnet_ids = [module.azure_network_subnet.subnet_id]
}

Providers

Name Version
azurecaf ~> 1.2, >= 1.2.22
azurerm ~> 3.0

Modules

No modules.

Resources

Name Type
azurerm_nat_gateway.natgw resource
azurerm_nat_gateway_public_ip_association.pip_assoc resource
azurerm_nat_gateway_public_ip_association.pip_assoc_custom_ips resource
azurerm_public_ip.pip resource
azurerm_subnet_nat_gateway_association.subnet_assoc resource
azurecaf_name.nat data source
azurecaf_name.pip_nat data source

Inputs

Name Description Type Default Required
client_name Client name/account used in naming string n/a yes
create_public_ip Should we create a public IP or not? bool true no
default_tags_enabled Option to enable or disable default tags bool true no
environment Project environment string n/a yes
extra_tags Extra tags to add map(string) {} no
location Azure region to use string n/a yes
location_short Short name of Azure region to use string n/a yes
name_prefix Optional prefix for the generated name string "" no
name_suffix Optional suffix for the generated name string "" no
nat_gateway_custom_name Custom name for Nat gateway string null no
nat_gateway_idle_timeout Idle timeout configuration in minutes for Nat Gateway number 4 no
public_ip_custom_name Custom name for public IP string null no
public_ip_domain_name_label DNS domain label for NAT Gateway public IP. string null no
public_ip_ids List of public ips to use. Create one ip if not provided list(string) [] no
public_ip_reverse_fqdn Reverse FQDN for NAT Gateway public IP. string null no
public_ip_zones Public ip Zones to configure. list(string) null no
resource_group_name Name of the resource group to use string n/a yes
stack Project stack name string n/a yes
subnet_ids Ids of subnets to associate with the Nat Gateway list(string) n/a yes
use_caf_naming Use the Azure CAF naming provider to generate default resource name. nat_gateway_custom_name override this if set. Legacy default name is used if this is set to false. bool true no

Outputs

Name Description
nat_gateway_id Nat Gateway Id
nat_gateway_name Nat gateway Name
nat_gateway_public_ip_ids Id of public IPs
nat_gateway_public_ips Public IPs associated to Nat Gateway

Related documentation

Azure NAT Gateway documentation: docs.microsoft.com/en-us/azure/virtual-network/nat-gateway-resource

Azure public IP documentation: docs.microsoft.com/en-us/azure/virtual-network/public-ip-addresses