Skip to content

Commit 3ac6496

Browse files
authored
feat(TPG>6.28)!: added support for packet mirroring firewall policy rule, src_networks, src_network_scope and dest_network_scope (#596)
1 parent c5ee576 commit 3ac6496

File tree

58 files changed

+653
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+653
-98
lines changed

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,34 @@ It supports creating:
99
- Secondary ranges for the subnets (if applicable)
1010
- routes
1111
- firewall rules
12-
13-
[Sub modules](./modules/) are provided for creating individual vpc, subnets, routes, firewall rules, and firewall policies. See the [modules](./modules/) directory for the various sub modules usage.
14-
- [vpc](./modules/vpc/)
15-
- [subnet](./modules/subnets/)
16-
- [route](./modules/routes/)
17-
- [firewall rules](./modules/firewall-rules/)
18-
- [hierarchical firewall policy](./modules/hierarchical-firewall-policy/)
19-
- [network firewall policy](./modules/network-firewall-policy/)
20-
- [serverless vpc access connector](./modules/vpc-serverless-connector-beta/)
21-
- [hierarchical firewall policy](./modules/hierarchical-firewall-policy/)
12+
- network firewall policy
13+
- hierarchical firewall policy
14+
- serverless vpc access connector
15+
- network connectivity center
16+
17+
[Sub modules](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules) are provided for creating individual vpc, subnets, routes, firewall rules, network firewall policies, hierarchical firewall policy, serverless vpc access connector and network connectivity center. See the [modules](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules) directory for the various sub modules usage.
18+
- [vpc](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/vpc)
19+
- [subnet](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/subnets/)
20+
- [route](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/routes)
21+
- [firewall rules](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/firewall-rules)
22+
- [network firewall policy](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/network-firewall-policy)
23+
- [hierarchical firewall policy](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/hierarchical-firewall-policy)
24+
- [serverless vpc access connector](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/vpc-serverless-connector-beta)
25+
- [network connectivity center](https://github.com/terraform-google-modules/terraform-google-network/tree/main/modules/network-connectivity-center)
2226

2327
## Compatibility
2428

25-
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.4+.
29+
This module is meant for use with Terraform 1.3+.
2630
If you find incompatibilities using Terraform `>=1.3`, please open an issue.
2731

2832

2933
## Usage
30-
You can go to the [examples](./examples/) folder, however the usage of the module could be like this in your own main.tf file:
34+
Comprehensive examples are available in [examples](https://github.com/terraform-google-modules/terraform-google-network/tree/main/examples) folder. Simple usage:
3135

3236
```hcl
3337
module "vpc" {
3438
source = "terraform-google-modules/network/google"
35-
version = "~> 10.0"
39+
version = "~> 11.0"
3640
3741
project_id = "<PROJECT ID>"
3842
network_name = "example-vpc"
@@ -191,9 +195,6 @@ The routes list contains maps, where each object represents a route. For the nex
191195
## Requirements
192196
### Installed Software
193197
- [Terraform](https://www.terraform.io/downloads.html) >= 1.3
194-
- [Terraform Provider for GCP](https://github.com/terraform-providers/terraform-provider-google) >= 4.25
195-
- [Terraform Provider for GCP Beta](https://github.com/terraform-providers/terraform-provider-google-beta) >= 4.25
196-
- [gcloud](https://cloud.google.com/sdk/gcloud/) >243.0.0
197198

198199
### Configure a Service Account
199200
In order to execute this module you must have a Service Account with the following roles:
@@ -214,6 +215,3 @@ In order to operate with the Service Account you must activate the following API
214215

215216
Refer to the [contribution guidelines](./CONTRIBUTING.md) for
216217
information on contributing to this module.
217-
218-
[terraform-0.13-upgrade]: https://www.terraform.io/upgrade-guides/0-13.html
219-
[2.6.0]: https://registry.terraform.io/modules/terraform-google-modules/network/google/2.6.0

docs/upgrading_to_v11.0.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Upgrading to v11.0.0
2+
3+
The v11.0 release contains backwards-incompatible changes.
4+
5+
This update requires upgrading:
6+
- minimum provider version of `hashicorp/google` to `6.28` and `hashicorp/google-beta` to `6.28` for network-firewall-policy sub-module.
7+
- minimum provider version of `hashicorp/google` to `6.19` for vpc sub-module.
8+
- minimum provider version of `hashicorp/google` to `6.18` for hierarchical-firewall-policy sub-module.

examples/global-network-firewall-policy/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Network Firewall Policy Rule
22

3-
This example creates a VPC network, Service Account, tag, address group and 2 `global` network firewall policy. First policy will have a few rules and will be attached to a VPC network. Second policy will not be attached and any VPC and will not have any rules.
3+
This example creates a VPC network, Service Account, tag, address group and 2 `global` network firewall policy. First policy will have a few rules and will be attached to a VPC network. Second policy will not be attached and any VPC and will not have any rules. It also creates a packet mirroring rule for out of band network service integration.
44

55
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
66
## Inputs
77

88
| Name | Description | Type | Default | Required |
99
|------|-------------|------|---------|:--------:|
10+
| org\_id | The project ID to host the network in | `any` | n/a | yes |
1011
| project\_id | The project ID to host the network in | `any` | n/a | yes |
1112

1213
## Outputs

examples/global-network-firewall-policy/main.tf

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,62 @@ resource "google_service_account" "service_account" {
7474
display_name = "${local.prefix} firewall policy test service account"
7575
}
7676

77+
################################
78+
# VPC Spoke #
79+
################################
80+
module "vpc" {
81+
source = "terraform-google-modules/network/google//modules/vpc"
82+
version = "~> 10.0"
83+
84+
project_id = var.project_id
85+
network_name = "global-sec-policy-test-vpc"
86+
87+
# shared_vpc_host = false
88+
}
89+
90+
resource "google_network_security_mirroring_deployment_group" "mirroring_deployment_group" {
91+
project = var.project_id
92+
mirroring_deployment_group_id = "${local.prefix}-mirroring-dg"
93+
location = "global"
94+
description = "suricata mirroring deployment group"
95+
network = module.vpc.network_id
96+
}
97+
98+
resource "google_network_security_mirroring_endpoint_group" "mirroring_endpoint_group" {
99+
provider = google-beta
100+
project = var.project_id
101+
mirroring_endpoint_group_id = "${local.prefix}-mirroring-eg"
102+
location = "global"
103+
description = "suricata mirroring endpoint group"
104+
mirroring_deployment_group = google_network_security_mirroring_deployment_group.mirroring_deployment_group.id
105+
}
106+
107+
108+
resource "google_network_security_security_profile" "security_profile" {
109+
provider = google-beta
110+
name = "${local.prefix}-security-profile"
111+
parent = "organizations/${var.org_id}"
112+
description = "Security profile description"
113+
type = "CUSTOM_MIRRORING"
114+
115+
custom_mirroring_profile {
116+
mirroring_endpoint_group = google_network_security_mirroring_endpoint_group.mirroring_endpoint_group.id
117+
}
118+
}
119+
120+
resource "google_network_security_security_profile_group" "security_profile_group" {
121+
provider = google-beta
122+
name = "${local.prefix}-sec-profile-group"
123+
parent = "organizations/${var.org_id}"
124+
description = "Security profile group"
125+
custom_mirroring_profile = google_network_security_security_profile.security_profile.id
126+
}
127+
128+
129+
77130
module "firewal_policy" {
78131
source = "terraform-google-modules/network/google//modules/network-firewall-policy"
79-
version = "~> 10.0"
132+
version = "~> 11.0"
80133

81134
project_id = var.project_id
82135
policy_name = "${local.prefix}-firewall-policy-${random_string.random_suffix.result}"
@@ -205,6 +258,27 @@ module "firewal_policy" {
205258
]
206259
}
207260
},
261+
{
262+
is_mirroring = true
263+
priority = "200"
264+
direction = "EGRESS"
265+
action = "mirror"
266+
rule_name = "egress-200"
267+
disabled = false
268+
description = "test egress mirroring rule 200"
269+
target_service_accounts = ["fw-test-svc-acct@${var.project_id}.iam.gserviceaccount.com"]
270+
match = {
271+
src_ip_ranges = ["0.0.0.0/0"]
272+
dest_ip_ranges = ["0.0.0.0/0"]
273+
layer4_configs = [
274+
{
275+
ip_protocol = "tcp"
276+
ports = ["80"]
277+
}
278+
]
279+
}
280+
security_profile_group_id = google_network_security_security_profile_group.security_profile_group.id
281+
},
208282

209283
]
210284

@@ -216,7 +290,7 @@ module "firewal_policy" {
216290

217291
module "firewal_policy_no_rule" {
218292
source = "terraform-google-modules/network/google//modules/network-firewall-policy"
219-
version = "~> 10.0"
293+
version = "~> 11.0"
220294
project_id = var.project_id
221295
policy_name = "${local.prefix}-firewall-policy-no-rules-${random_string.random_suffix.result}"
222296
description = "${local.prefix} test firewall policy without any rules"

examples/global-network-firewall-policy/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717
variable "project_id" {
1818
description = "The project ID to host the network in"
1919
}
20+
21+
variable "org_id" {
22+
description = "The project ID to host the network in"
23+
}

examples/hierarchical-firewall-policy/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ resource "google_compute_network" "network_backup" {
4343

4444
module "firewal_policy" {
4545
source = "terraform-google-modules/network/google//modules/hierarchical-firewall-policy"
46-
version = "~> 10.0"
46+
version = "~> 11.0"
4747

4848
parent_node = "folders/${var.folder1}"
4949
policy_name = "${local.prefix}-firewall-policy-${random_string.random_suffix.result}"
@@ -181,7 +181,7 @@ module "firewal_policy" {
181181

182182
module "firewal_policy_no_rule" {
183183
source = "terraform-google-modules/network/google//modules/hierarchical-firewall-policy"
184-
version = "~> 10.0"
184+
version = "~> 11.0"
185185

186186
parent_node = "folders/${var.folder1}"
187187
policy_name = "${local.prefix}-firewall-policy-no-rules-${random_string.random_suffix.result}"

metadata.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ spec:
3939
location: modules/firewall-rules
4040
- name: hierarchical-firewall-policy
4141
location: modules/hierarchical-firewall-policy
42+
- name: network-connectivity-center
43+
location: modules/network-connectivity-center
4244
- name: network-firewall-policy
4345
location: modules/network-firewall-policy
4446
- name: network-peering
@@ -84,6 +86,8 @@ spec:
8486
location: examples/ilb_routing
8587
- name: multi_vpc
8688
location: examples/multi_vpc
89+
- name: network_connectivity_center
90+
location: examples/network_connectivity_center
8791
- name: network_service_tiers
8892
location: examples/network_service_tiers
8993
- name: packet_mirroring
@@ -228,6 +232,14 @@ spec:
228232
description: The name of the network being created
229233
varType: string
230234
required: true
235+
- name: network_profile
236+
description: |
237+
"A full or partial URL of the network profile to apply to this network.
238+
This field can be set only at resource creation time. For example, the
239+
following are valid URLs:
240+
* https://www.googleapis.com/compute/beta/projects/{projectId}/global/networkProfiles/{network_profile_name}
241+
* projects/{projectId}/global/networkProfiles/{network_profile_name}
242+
varType: string
231243
- name: project_id
232244
description: The ID of the project where this VPC will be created
233245
varType: string
@@ -305,6 +317,7 @@ spec:
305317
roles:
306318
- level: Project
307319
roles:
320+
- roles/compute.instanceAdmin
308321
- roles/compute.networkAdmin
309322
- roles/compute.securityAdmin
310323
- roles/iam.serviceAccountUser
@@ -314,11 +327,21 @@ spec:
314327
- roles/resourcemanager.tagAdmin
315328
- roles/iam.serviceAccountAdmin
316329
- roles/compute.orgFirewallPolicyAdmin
330+
- roles/networkconnectivity.hubAdmin
331+
- roles/networksecurity.mirroringDeploymentAdmin
332+
- roles/networksecurity.mirroringEndpointAdmin
333+
- roles/networksecurity.securityProfileAdmin
317334
services:
318335
- cloudresourcemanager.googleapis.com
319336
- compute.googleapis.com
320337
- serviceusage.googleapis.com
321338
- vpcaccess.googleapis.com
322339
- dns.googleapis.com
323340
- networksecurity.googleapis.com
341+
- networkconnectivity.googleapis.com
324342
- iam.googleapis.com
343+
providerVersions:
344+
- source: hashicorp/google
345+
version: ">= 4.64, < 7"
346+
- source: hashicorp/google-beta
347+
version: ">= 4.64, < 7"

modules/fabric-net-firewall/metadata.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ spec:
5858
location: examples/ilb_routing
5959
- name: multi_vpc
6060
location: examples/multi_vpc
61+
- name: network_connectivity_center
62+
location: examples/network_connectivity_center
6163
- name: network_service_tiers
6264
location: examples/network_service_tiers
6365
- name: packet_mirroring
@@ -190,6 +192,7 @@ spec:
190192
roles:
191193
- level: Project
192194
roles:
195+
- roles/compute.instanceAdmin
193196
- roles/compute.networkAdmin
194197
- roles/compute.securityAdmin
195198
- roles/iam.serviceAccountUser
@@ -199,11 +202,21 @@ spec:
199202
- roles/resourcemanager.tagAdmin
200203
- roles/iam.serviceAccountAdmin
201204
- roles/compute.orgFirewallPolicyAdmin
205+
- roles/networkconnectivity.hubAdmin
206+
- roles/networksecurity.mirroringDeploymentAdmin
207+
- roles/networksecurity.mirroringEndpointAdmin
208+
- roles/networksecurity.securityProfileAdmin
202209
services:
203210
- cloudresourcemanager.googleapis.com
204211
- compute.googleapis.com
205212
- serviceusage.googleapis.com
206213
- vpcaccess.googleapis.com
207214
- dns.googleapis.com
208215
- networksecurity.googleapis.com
216+
- networkconnectivity.googleapis.com
209217
- iam.googleapis.com
218+
providerVersions:
219+
- source: hashicorp/google
220+
version: ">= 4.64, < 7"
221+
- source: hashicorp/google-beta
222+
version: ">= 4.64, < 7"

modules/fabric-net-firewall/versions.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
terraform {
1818
required_version = ">= 1.3"
19+
1920
required_providers {
2021
google = {
2122
source = "hashicorp/google"

modules/fabric-net-svpc-access/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Basic usage of this module is as follows:
1919
```hcl
2020
module "net-shared-vpc-access" {
2121
source = "terraform-google-modules/network/google//modules/fabric-net-svpc-access"
22-
version = "~> 1.4.0"
22+
version = "~> 11.0"
23+
2324
host_project_id = "my-host-project-id"
2425
service_project_num = 1
2526
service_project_ids = ["my-service-project-id"]

0 commit comments

Comments
 (0)