Skip to content

Commit 36d1c55

Browse files
tuunitapeabody
andauthored
fix: align subnet modules (#412)
Co-authored-by: Andrew Peabody <[email protected]>
1 parent 67cce5a commit 36d1c55

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

modules/subnets-beta/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ It supports creating:
66

77
- Subnets within vpc network.
88

9-
It also uses google beta provider to support the following resource fields:
10-
11-
- google_compute_subnetwork.purpose
12-
- google_compute_subnetwork.role
13-
149
## Usage
1510

1611
Basic usage of this submodule is as follows:
@@ -47,6 +42,7 @@ module "vpc" {
4742
subnet_flow_logs_interval = "INTERVAL_10_MIN"
4843
subnet_flow_logs_sampling = 0.7
4944
subnet_flow_logs_metadata = "INCLUDE_ALL_METADATA"
45+
subnet_flow_logs_filter_expr = "true"
5046
}
5147
]
5248
@@ -86,10 +82,16 @@ module "vpc" {
8682

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

89-
| Name | Description | Type | Default | Required |
90-
|------|-------------|:----:|:-----:|:-----:|
91-
| subnet\_name | The name of the subnet being created | string | - | yes |
92-
| subnet\_ip | The IP and CIDR range of the subnet being created | string | - | yes |
93-
| subnet\_region | The region where the subnet will be created | string | - | yes |
94-
| subnet\_private\_access | Whether this subnet will have private Google access enabled | string | `"false"` | no |
95-
| subnet\_flow\_logs | Whether the subnet will record and send flow log data to logging | string | `"false"` | no |
85+
| Name | Description | Type | Default | Required |
86+
| ---------------------------- | --------------------------------------------------------------------------------------------------------------- | :----: | :----------------------: | :------: |
87+
| subnet\_name | The name of the subnet being created | string | - | yes |
88+
| subnet\_ip | The IP and CIDR range of the subnet being created | string | - | yes |
89+
| subnet\_region | The region where the subnet will be created | string | - | yes |
90+
| subnet\_private\_access | Whether this subnet will have private Google access enabled | string | `"false"` | no |
91+
| subnet\_flow\_logs | Whether the subnet will record and send flow log data to logging | string | `"false"` | no |
92+
| subnet\_flow\_logs\_interval | If subnet\_flow\_logs is true, sets the aggregation interval for collecting flow logs | string | `"INTERVAL_5_SEC"` | no |
93+
| 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 |
94+
| 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+
| 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 |
97+
| 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 |

modules/subnets-beta/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ resource "google_compute_subnetwork" "subnetwork" {
3737
aggregation_interval = lookup(each.value, "subnet_flow_logs_interval", "INTERVAL_5_SEC")
3838
flow_sampling = lookup(each.value, "subnet_flow_logs_sampling", "0.5")
3939
metadata = lookup(each.value, "subnet_flow_logs_metadata", "INCLUDE_ALL_METADATA")
40+
filter_expr = lookup(each.value, "subnet_flow_logs_filter", "true")
4041
}] : []
4142
content {
4243
aggregation_interval = log_config.value.aggregation_interval
4344
flow_sampling = log_config.value.flow_sampling
4445
metadata = log_config.value.metadata
46+
filter_expr = log_config.value.filter_expr
4547
}
4648
}
4749
network = var.network_name

modules/subnets/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module "vpc" {
3131
subnet_private_access = "true"
3232
subnet_flow_logs = "true"
3333
description = "This subnet has a description"
34+
purpose = "INTERNAL_HTTPS_LOAD_BALANCER"
35+
role = "ACTIVE"
3436
},
3537
{
3638
subnet_name = "subnet-03"
@@ -90,3 +92,5 @@ The subnets list contains maps, where each object represents a subnet. Each map
9092
| 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 |
9193
| 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 |
9294
| 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 |
95+
| 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 |
96+
| 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 |

0 commit comments

Comments
 (0)