diff --git a/modules/net-cloudnat/README.md b/modules/net-cloudnat/README.md
index 64342ad33c..9e18ff644d 100644
--- a/modules/net-cloudnat/README.md
+++ b/modules/net-cloudnat/README.md
@@ -63,7 +63,6 @@ module "nat" {
# tftest modules=2 resources=5 inventory=rules.yaml
```
-
## Variables
| name | description | type | required | default |
@@ -76,7 +75,7 @@ module "nat" {
| [config_source_subnets](variables.tf#L39) | Subnetwork configuration (ALL_SUBNETWORKS_ALL_IP_RANGES, ALL_SUBNETWORKS_ALL_PRIMARY_IP_RANGES, LIST_OF_SUBNETWORKS). | string
| | "ALL_SUBNETWORKS_ALL_IP_RANGES"
|
| [config_timeouts](variables.tf#L45) | Timeout configurations. | object({…})
| | {}
|
| [logging_filter](variables.tf#L57) | Enables logging if not null, value is one of 'ERRORS_ONLY', 'TRANSLATIONS_ONLY', 'ALL'. | string
| | null
|
-| [router_asn](variables.tf#L78) | Router ASN used for auto-created router. | number
| | 64514
|
+| [router_asn](variables.tf#L78) | Router ASN used for auto-created router. | number
| | null
|
| [router_create](variables.tf#L84) | Create router. | bool
| | true
|
| [router_name](variables.tf#L90) | Router name, leave blank if router will be created to use auto generated name. | string
| | null
|
| [router_network](variables.tf#L96) | Name of the VPC used for auto-created router. | string
| | null
|
@@ -93,5 +92,4 @@ module "nat" {
| [region](outputs.tf#L32) | Cloud NAT region. | |
| [router](outputs.tf#L37) | Cloud NAT router resources (if auto created). | |
| [router_name](outputs.tf#L46) | Cloud NAT router name. | |
-
diff --git a/modules/net-cloudnat/main.tf b/modules/net-cloudnat/main.tf
index 68613c4d47..6d1da01d8d 100644
--- a/modules/net-cloudnat/main.tf
+++ b/modules/net-cloudnat/main.tf
@@ -28,8 +28,12 @@ resource "google_compute_router" "router" {
project = var.project_id
region = var.region
network = var.router_network
- bgp {
- asn = var.router_asn
+
+ dynamic "bgp" {
+ for_each = var.router_asn == null ? [] : [1]
+ content {
+ asn = var.router_asn
+ }
}
}
diff --git a/modules/net-cloudnat/variables.tf b/modules/net-cloudnat/variables.tf
index abf0641506..ed2649aacc 100644
--- a/modules/net-cloudnat/variables.tf
+++ b/modules/net-cloudnat/variables.tf
@@ -78,7 +78,7 @@ variable "region" {
variable "router_asn" {
description = "Router ASN used for auto-created router."
type = number
- default = 64514
+ default = null
}
variable "router_create" {