Skip to content
Open
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ module "vpc" {
range_name = "subnet-01-secondary-01"
ip_cidr_range = "192.168.64.0/24"
},
{
range_name = "subnet-01-secondary-02"
reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range"
},
]

subnet-02 = []
Expand Down Expand Up @@ -128,7 +132,7 @@ Then perform the following commands on the root folder:
| project\_id | The ID of the project where this VPC will be created | `string` | n/a | yes |
| routes | List of routes being created in this VPC | `list(map(string))` | `[]` | no |
| routing\_mode | The network routing mode (default 'GLOBAL') | `string` | `"GLOBAL"` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no |
| shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | `bool` | `false` | no |
| subnets | The list of subnets being created | <pre>list(object({<br> subnet_name = string<br> subnet_ip = string<br> subnet_region = string<br> subnet_private_access = optional(string)<br> subnet_private_ipv6_access = optional(string)<br> subnet_flow_logs = optional(string)<br> subnet_flow_logs_interval = optional(string)<br> subnet_flow_logs_sampling = optional(string)<br> subnet_flow_logs_metadata = optional(string)<br> subnet_flow_logs_filter = optional(string)<br> subnet_flow_logs_metadata_fields = optional(list(string))<br> description = optional(string)<br> purpose = optional(string)<br> role = optional(string)<br> stack_type = optional(string)<br> ipv6_access_type = optional(string)<br> }))</pre> | n/a | yes |

Expand Down
5 changes: 5 additions & 0 deletions examples/secondary_ranges/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ module "vpc-secondary-ranges" {
range_name = "${local.subnet_03}-01"
ip_cidr_range = "192.168.66.0/24"
},
# Example of using reserved_internal_range instead of ip_cidr_range
# {
# range_name = "${local.subnet_03}-02"
# reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range"
# },
]
}

Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ spec:
required: true
- name: secondary_ranges
description: Secondary ranges that will be used in some of the subnets
varType: map(list(object({ range_name = string, ip_cidr_range = string })))
varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
defaultValue: {}
- name: routes
description: List of routes being created in this VPC
Expand Down
6 changes: 5 additions & 1 deletion modules/subnets-beta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module "vpc" {
range_name = "subnet-01-secondary-01"
ip_cidr_range = "192.168.64.0/24"
},
{
range_name = "subnet-01-secondary-02"
reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range"
},
]

subnet-02 = []
Expand All @@ -67,7 +71,7 @@ module "vpc" {
| module\_depends\_on | List of modules or resources this module depends on. | `list(any)` | `[]` | no |
| network\_name | The name of the network where subnets will be created | `string` | n/a | yes |
| project\_id | The ID of the project where subnets will be created | `string` | n/a | yes |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no |
| subnets | The list of subnets being created | <pre>list(object({<br> subnet_name = string<br> subnet_ip = string<br> subnet_region = string<br> subnet_private_access = optional(string, "false")<br> subnet_private_ipv6_access = optional(string)<br> subnet_flow_logs = optional(bool, false)<br> subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")<br> subnet_flow_logs_sampling = optional(string, "0.5")<br> subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")<br> subnet_flow_logs_filter = optional(string, "true")<br> subnet_flow_logs_metadata_fields = optional(list(string), [])<br> description = optional(string)<br> purpose = optional(string)<br> role = optional(string)<br> stack_type = optional(string)<br> ipv6_access_type = optional(string)<br> }))</pre> | n/a | yes |

## Outputs
Expand Down
5 changes: 3 additions & 2 deletions modules/subnets-beta/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ resource "google_compute_subnetwork" "subnetwork" {
for_each = contains(keys(var.secondary_ranges), each.value.subnet_name) == true ? var.secondary_ranges[each.value.subnet_name] : []

content {
range_name = secondary_ip_range.value.range_name
ip_cidr_range = secondary_ip_range.value.ip_cidr_range
range_name = secondary_ip_range.value.range_name
ip_cidr_range = secondary_ip_range.value.ip_cidr_range
reserved_internal_range = secondary_ip_range.value.reserved_internal_range
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/subnets-beta/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
required: true
- name: secondary_ranges
description: Secondary ranges that will be used in some of the subnets
varType: map(list(object({ range_name = string, ip_cidr_range = string })))
varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
defaultValue: {}
- name: module_depends_on
description: List of modules or resources this module depends on.
Expand Down
2 changes: 1 addition & 1 deletion modules/subnets-beta/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ variable "subnets" {
}

variable "secondary_ranges" {
type = map(list(object({ range_name = string, ip_cidr_range = string })))
type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
description = "Secondary ranges that will be used in some of the subnets"
default = {}
}
Expand Down
6 changes: 5 additions & 1 deletion modules/subnets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module "vpc" {
range_name = "subnet-01-secondary-01"
ip_cidr_range = "192.168.64.0/24"
},
{
range_name = "subnet-01-secondary-02"
reserved_internal_range = "networkconnectivity.googleapis.com/projects/my-project/locations/global/internalRanges/my-range"
},
]

subnet-02 = []
Expand All @@ -66,7 +70,7 @@ module "vpc" {
|------|-------------|------|---------|:--------:|
| network\_name | The name of the network where subnets will be created | `string` | n/a | yes |
| project\_id | The ID of the project where subnets will be created | `string` | n/a | yes |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))` | `{}` | no |
| subnets | The list of subnets being created | <pre>list(object({<br> subnet_name = string<br> subnet_ip = string<br> subnet_region = string<br> subnet_private_access = optional(string, "false")<br> subnet_private_ipv6_access = optional(string)<br> subnet_flow_logs = optional(string, "false")<br> subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")<br> subnet_flow_logs_sampling = optional(string, "0.5")<br> subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")<br> subnet_flow_logs_filter = optional(string, "true")<br> subnet_flow_logs_metadata_fields = optional(list(string), [])<br> description = optional(string)<br> purpose = optional(string)<br> role = optional(string)<br> stack_type = optional(string)<br> ipv6_access_type = optional(string)<br> }))</pre> | n/a | yes |

## Outputs
Expand Down
5 changes: 3 additions & 2 deletions modules/subnets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ resource "google_compute_subnetwork" "subnetwork" {
for_each = contains(keys(var.secondary_ranges), each.value.subnet_name) == true ? var.secondary_ranges[each.value.subnet_name] : []

content {
range_name = secondary_ip_range.value.range_name
ip_cidr_range = secondary_ip_range.value.ip_cidr_range
range_name = secondary_ip_range.value.range_name
ip_cidr_range = secondary_ip_range.value.ip_cidr_range
reserved_internal_range = secondary_ip_range.value.reserved_internal_range
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/subnets/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ spec:
required: true
- name: secondary_ranges
description: Secondary ranges that will be used in some of the subnets
varType: map(list(object({ range_name = string, ip_cidr_range = string })))
varType: map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
defaultValue: {}
outputs:
- name: subnets
Expand Down
2 changes: 1 addition & 1 deletion modules/subnets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ variable "subnets" {
}

variable "secondary_ranges" {
type = map(list(object({ range_name = string, ip_cidr_range = string })))
type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
description = "Secondary ranges that will be used in some of the subnets"
default = {}
}
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ variable "subnets" {
}

variable "secondary_ranges" {
type = map(list(object({ range_name = string, ip_cidr_range = string })))
type = map(list(object({ range_name = string, ip_cidr_range = optional(string), reserved_internal_range = optional(string) })))
description = "Secondary ranges that will be used in some of the subnets"
default = {}
}
Expand Down