Skip to content

Commit 71a1177

Browse files
authored
fix: added missing variables (#481)
1 parent 2dde9d8 commit 71a1177

File tree

8 files changed

+64
-35
lines changed

8 files changed

+64
-35
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Then perform the following commands on the root folder:
110110
| routing\_mode | The network routing mode (default 'GLOBAL') | `string` | `"GLOBAL"` | no |
111111
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
112112
| shared\_vpc\_host | Makes this project a Shared VPC host if 'true' (default 'false') | `bool` | `false` | no |
113-
| 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> }))</pre> | n/a | yes |
113+
| 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 |
114114

115115
## Outputs
116116

@@ -138,13 +138,25 @@ Then perform the following commands on the root folder:
138138

139139
The subnets list contains maps, where each object represents a subnet. Each map has the following inputs (please see examples folder for additional references):
140140

141-
| Name | Description | Type | Default | Required |
142-
|------|-------------|:----:|:-----:|:-----:|
143-
| subnet\_name | The name of the subnet being created | string | - | yes |
144-
| subnet\_ip | The IP and CIDR range of the subnet being created | string | - | yes |
145-
| subnet\_region | The region where the subnet will be created | string | - | yes |
146-
| subnet\_private\_access | Whether this subnet will have private Google access enabled | string | `"false"` | no |
147-
| subnet\_flow\_logs | Whether the subnet will record and send flow log data to logging | string | `"false"` | no |
141+
| Name | Description | Type | Default | Required |
142+
| ---------------------------- | --------------------------------------------------------------------------------------------------------------- | :----: | :----------------------: | :------: |
143+
| subnet\_name | The name of the subnet being created | string | - | yes |
144+
| subnet\_ip | The IP and CIDR range of the subnet being created | string | - | yes |
145+
| subnet\_region | The region where the subnet will be created | string | - | yes |
146+
| subnet\_private\_access | Whether this subnet will have private Google access enabled | string | `"false"` | no |
147+
| subnet\_private\_ipv6\_access| The private IPv6 google access type for the VMs in this subnet | string | - | no |
148+
| subnet\_flow\_logs | Whether the subnet will record and send flow log data to logging | string | `"false"` | no |
149+
| subnet\_flow\_logs\_interval | If subnet\_flow\_logs is true, sets the aggregation interval for collecting flow logs | string | `"INTERVAL_5_SEC"` | no |
150+
| subnet\_flow\_logs\_sampling | If subnet\_flow\_logs is true, set the sampling rate of VPC flow logs within the subnetwork | string | `"0.5"` | no |
151+
| subnet\_flow\_logs\_metadata | If subnet\_flow\_logs is true, configures whether metadata fields should be added to the reported VPC flow logs | string | `"INCLUDE_ALL_METADATA"` | no |
152+
| subnet\_flow\_logs\_filter | Export filter defining which VPC flow logs should be logged, see https://cloud.google.com/vpc/docs/flow-logs#filtering for formatting details | string | `"true"` | no |
153+
| subnet\_flow\_logs\_metadata\_fields | List of metadata fields that should be added to reported logs. Can only be specified if VPC flow logs for this subnetwork is enabled and "metadata" is set to CUSTOM_METADATA. | any | - | no |
154+
| description | An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time | string | - | no |
155+
| purpose | The purpose of the subnet usage. Whether it is to be used as a regular subnet or for proxy or loadbalacing purposes, see https://cloud.google.com/vpc/docs/subnets#purpose for more details | string | `"PRIVATE"` | no |
156+
| role | The role of the subnet when using it as a proxy or loadbalancer network. Whether it is to be used as the active or as a backup subnet, see https://cloud.google.com/load-balancing/docs/proxy-only-subnets#proxy_only_subnet_create for more details | string | - | no |
157+
| stack\_type | `IPV4_ONLY` or `IPV4_IPV6` for dual-stack networking | string | - | no |
158+
| ipv6\_access\_type | `INTERNAL` or `EXTERNAL`. `INTERNAL` requires ULA be enabled on the VPC | string | - | no |
159+
148160

149161
### Route Inputs
150162

modules/subnets-beta/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module "vpc" {
6868
| network\_name | The name of the network where subnets will be created | `string` | n/a | yes |
6969
| project\_id | The ID of the project where subnets will be created | `string` | n/a | yes |
7070
| secondary\_ranges | Secondary ranges that will be used in some of the subnets | `map(list(object({ range_name = string, ip_cidr_range = string })))` | `{}` | no |
71-
| 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, "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> }))</pre> | n/a | yes |
71+
| 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 |
7272

7373
## Outputs
7474

@@ -88,14 +88,15 @@ The subnets list contains maps, where each object represents a subnet. Each map
8888
| subnet\_ip | The IP and CIDR range of the subnet being created | string | - | yes |
8989
| subnet\_region | The region where the subnet will be created | string | - | yes |
9090
| subnet\_private\_access | Whether this subnet will have private Google access enabled | string | `"false"` | no |
91+
| subnet\_private\_ipv6\_access| The private IPv6 google access type for the VMs in this subnet | string | - | no |
9192
| subnet\_flow\_logs | Whether the subnet will record and send flow log data to logging | string | `"false"` | no |
9293
| subnet\_flow\_logs\_interval | If subnet\_flow\_logs is true, sets the aggregation interval for collecting flow logs | string | `"INTERVAL_5_SEC"` | no |
9394
| subnet\_flow\_logs\_sampling | If subnet\_flow\_logs is true, set the sampling rate of VPC flow logs within the subnetwork | string | `"0.5"` | no |
9495
| subnet\_flow\_logs\_metadata | If subnet\_flow\_logs is true, configures whether metadata fields should be added to the reported VPC flow logs | string | `"INCLUDE_ALL_METADATA"` | no |
95-
| subnet\_flow\_logs\_filter_expr | Export filter defining which VPC flow logs should be logged, see https://cloud.google.com/vpc/docs/flow-logs#filtering for formatting details | string | `"true"` | no |
96+
| subnet\_flow\_logs\_filter | Export filter defining which VPC flow logs should be logged, see https://cloud.google.com/vpc/docs/flow-logs#filtering for formatting details | string | `"true"` | no |
9697
| subnet\_flow\_logs\_metadata\_fields | List of metadata fields that should be added to reported logs. Can only be specified if VPC flow logs for this subnetwork is enabled and "metadata" is set to CUSTOM_METADATA. | any | - | no |
98+
| description | An optional description of this resource. Provide this property when you create the resource. This field can be set only at resource creation time | string | - | no |
9799
| purpose | The purpose of the subnet usage. Whether it is to be used as a regular subnet or for proxy or loadbalacing purposes, see https://cloud.google.com/vpc/docs/subnets#purpose for more details | string | `"PRIVATE"` | no |
98-
| role | The role of the subnet when using it as a proxy or loadbalancer network. Whether it is to be used as the active or as a backup subnet, see https://cloud.google.com/load-balancing/docs/proxy-only-subnets#proxy_only_subnet_create for more details | string | - | no |
99-
| enable\_ipv6\_ula | Enabled IPv6 ULA, this is a permenant change and cannot be undone! (default 'false') | `bool` | `false` | no |
100-
| internal\_ipv6\_range | When enabling IPv6 ULA, optionally, specify a /48 from fd20::/20 (default null) | `string` | `null` | no |
101-
100+
| role | The role of the subnet when using it as a proxy or loadbalancer network. Whether it is to be used as the active or as a backup subnet, see https://cloud.google.com/load-balancing/docs/proxy-only-subnets#proxy_only_subnet_create for more details | string | - | no |
101+
| stack\_type | `IPV4_ONLY` or `IPV4_IPV6` for dual-stack networking | string | - | no |
102+
| ipv6\_access\_type | `INTERNAL` or `EXTERNAL`. `INTERNAL` requires ULA be enabled on the VPC | string | - | no |

modules/subnets-beta/main.tf

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ locals {
2626
Subnet configuration
2727
*****************************************/
2828
resource "google_compute_subnetwork" "subnetwork" {
29-
provider = google-beta
30-
for_each = local.subnets
31-
name = each.value.subnet_name
32-
ip_cidr_range = each.value.subnet_ip
33-
region = each.value.subnet_region
34-
private_ip_google_access = lookup(each.value, "subnet_private_access", "false")
29+
provider = google-beta
30+
for_each = local.subnets
31+
name = each.value.subnet_name
32+
ip_cidr_range = each.value.subnet_ip
33+
region = each.value.subnet_region
34+
private_ip_google_access = lookup(each.value, "subnet_private_access", "false")
35+
private_ipv6_google_access = lookup(each.value, "subnet_private_ipv6_access", null)
3536
dynamic "log_config" {
3637
for_each = coalesce(lookup(each.value, "subnet_flow_logs", null), false) ? [{
3738
aggregation_interval = each.value.subnet_flow_logs_interval
@@ -45,7 +46,7 @@ resource "google_compute_subnetwork" "subnetwork" {
4546
flow_sampling = log_config.value.flow_sampling
4647
metadata = log_config.value.metadata
4748
filter_expr = log_config.value.filter_expr
48-
metadata_fields = log_config.value.metadata_fields
49+
metadata_fields = log_config.value.metadata == "CUSTOM_METADATA" ? log_config.value.metadata_fields : null
4950
}
5051
}
5152
network = var.network_name
@@ -64,8 +65,8 @@ resource "google_compute_subnetwork" "subnetwork" {
6465

6566
purpose = lookup(each.value, "purpose", null)
6667
role = lookup(each.value, "role", null)
67-
stack_type = lookup(each.value, "stack", null)
68-
ipv6_access_type = lookup(each.value, "ipv6_type", null)
68+
stack_type = lookup(each.value, "stack_type", null)
69+
ipv6_access_type = lookup(each.value, "ipv6_access_type", null)
6970

7071
depends_on = [var.module_depends_on]
7172
}

modules/subnets-beta/variables.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ variable "subnets" {
2929
subnet_name = string
3030
subnet_ip = string
3131
subnet_region = string
32-
subnet_private_access = optional(string)
32+
subnet_private_access = optional(string, "false")
3333
subnet_private_ipv6_access = optional(string)
34-
subnet_flow_logs = optional(string)
34+
subnet_flow_logs = optional(bool, false)
3535
subnet_flow_logs_interval = optional(string, "INTERVAL_5_SEC")
3636
subnet_flow_logs_sampling = optional(string, "0.5")
3737
subnet_flow_logs_metadata = optional(string, "INCLUDE_ALL_METADATA")
3838
subnet_flow_logs_filter = optional(string, "true")
3939
subnet_flow_logs_metadata_fields = optional(list(string), [])
4040
description = optional(string)
41+
purpose = optional(string)
42+
role = optional(string)
43+
stack_type = optional(string)
44+
ipv6_access_type = optional(string)
4145
}))
4246
description = "The list of subnets being created"
4347
}

0 commit comments

Comments
 (0)