From 4ca9561c31e8220926f14b2ff29c535cd780960b Mon Sep 17 00:00:00 2001
From: Matias Piercamilli <38869168+Pierca7@users.noreply.github.com>
Date: Mon, 13 Nov 2023 22:37:26 +0100
Subject: [PATCH] Add NAT Gateway (#99)
* Add NAT Gateway resource
* Fix JSON format
---
README.md | 1 +
docs/missing_resources.md | 1 -
main.tf | 14 ++++++++++++++
outputs.tf | 8 +++++++-
resourceDefinition.json | 11 +++++++++++
5 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 371377a..2ee2090 100644
--- a/README.md
+++ b/README.md
@@ -273,6 +273,7 @@ No modules.
| [mysql\_firewall\_rule](#output\_mysql\_firewall\_rule) | Mysql Firewall Rule |
| [mysql\_server](#output\_mysql\_server) | Mysql Server |
| [mysql\_virtual\_network\_rule](#output\_mysql\_virtual\_network\_rule) | Mysql Virtual Network Rule |
+| [nat\_gateway](#output\_nat\_gateway) | NAT Gateway |
| [network\_ddos\_protection\_plan](#output\_network\_ddos\_protection\_plan) | Network Ddos Protection Plan |
| [network\_interface](#output\_network\_interface) | Network Interface |
| [network\_security\_group](#output\_network\_security\_group) | Network Security Group |
diff --git a/docs/missing_resources.md b/docs/missing_resources.md
index a72e208..b5134b0 100644
--- a/docs/missing_resources.md
+++ b/docs/missing_resources.md
@@ -24,7 +24,6 @@
- spatial_anchors_account
- scheduled_query_rule_log
- express_route_circuit_authorization
-- nat_gateway
- network_packet_capture
- network_profile
- packet_capture //deprecated
diff --git a/main.tf b/main.tf
index 3694efb..2703c33 100644
--- a/main.tf
+++ b/main.tf
@@ -1496,6 +1496,16 @@ locals {
scope = "parent"
regex = "^[a-zA-Z0-9-_]+$"
}
+ nat_gateway = {
+ name = substr(join("-", compact([local.prefix, "ng", local.suffix])), 0, 80)
+ name_unique = substr(join("-", compact([local.prefix, "ng", local.suffix_unique])), 0, 80)
+ dashes = true
+ slug = "ng"
+ min_length = 1
+ max_length = 80
+ scope = "resourceGroup"
+ regex = "^[a-zA-Z0-9][a-zA-Z0-9-._]+[a-zA-Z0-9_]$"
+ }
network_ddos_protection_plan = {
name = substr(join("-", compact([local.prefix, "ddospp", local.suffix])), 0, 80)
name_unique = substr(join("-", compact([local.prefix, "ddospp", local.suffix_unique])), 0, 80)
@@ -2998,6 +3008,10 @@ locals {
valid_name = length(regexall(local.az.mysql_virtual_network_rule.regex, local.az.mysql_virtual_network_rule.name)) > 0 && length(local.az.mysql_virtual_network_rule.name) > local.az.mysql_virtual_network_rule.min_length
valid_name_unique = length(regexall(local.az.mysql_virtual_network_rule.regex, local.az.mysql_virtual_network_rule.name_unique)) > 0
}
+ nat_gateway = {
+ valid_name = length(regexall(local.az.nat_gateway.regex, local.az.nat_gateway.name)) > 0 && length(local.az.nat_gateway.name) > local.az.nat_gateway.min_length
+ valid_name_unique = length(regexall(local.az.nat_gateway.regex, local.az.nat_gateway.name_unique)) > 0
+ }
network_ddos_protection_plan = {
valid_name = length(regexall(local.az.network_ddos_protection_plan.regex, local.az.network_ddos_protection_plan.name)) > 0 && length(local.az.network_ddos_protection_plan.name) > local.az.network_ddos_protection_plan.min_length
valid_name_unique = length(regexall(local.az.network_ddos_protection_plan.regex, local.az.network_ddos_protection_plan.name_unique)) > 0
diff --git a/outputs.tf b/outputs.tf
index 481ffb7..339fe31 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -27,7 +27,8 @@ output "app_service" {
}
output "app_service_environment" {
- value = local.az.app_service_environment
+ value = local.az.app_service_environment
+ description = "App Service Environment"
}
output "app_service_plan" {
@@ -735,6 +736,11 @@ output "mysql_virtual_network_rule" {
description = "Mysql Virtual Network Rule"
}
+output "nat_gateway" {
+ value = local.az.nat_gateway
+ description = "Nat Gateway"
+}
+
output "network_ddos_protection_plan" {
value = local.az.network_ddos_protection_plan
description = "Network Ddos Protection Plan"
diff --git a/resourceDefinition.json b/resourceDefinition.json
index cbb298c..3a5e02d 100644
--- a/resourceDefinition.json
+++ b/resourceDefinition.json
@@ -1407,6 +1407,17 @@
"slug": "mysqlvn",
"dashes": true
},
+ {
+ "name": "nat_gateway",
+ "length": {
+ "min": 1,
+ "max": 80
+ },
+ "regex": "^(?=.{1,80}$)[a-zA-Z0-9][a-zA-Z0-9-._]+[a-zA-Z0-9_]$",
+ "scope": "resourceGroup",
+ "slug": "ng",
+ "dashes": true
+ },
{
"name": "network_interface",
"length": {