Skip to content

Commit de58006

Browse files
authored
feat(TPG>=5.4)!: add vpc_network_sources in access level (#133)
1 parent 909a569 commit de58006

File tree

50 files changed

+1359
-48
lines changed

Some content is hidden

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

50 files changed

+1359
-48
lines changed

.kitchen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Google LLC
1+
# Copyright 2024 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2019 Google LLC
1+
# Copyright 2024 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.

docs/upgrading_to_v6.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
The v6.x release contains backwards-incompatible changes.
44

5-
This update requires upgrading the minimum provider version to `4.68`.
5+
This update requires upgrading the minimum provider version to `5.4`.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Simple Example Access Level
2+
3+
This example illustrates how to use the `vpc-service-controls` module to configure an org policy and an access level
4+
5+
# Requirements
6+
1. Make sure you've gone through the root [Requirement Section](../../#requirements)
7+
8+
9+
10+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
11+
## Inputs
12+
13+
| Name | Description | Type | Default | Required |
14+
|------|-------------|------|---------|:--------:|
15+
| parent\_id | The parent of this AccessPolicy in the Cloud Resource Hierarchy. As of now, only organization are accepted as parent. | `string` | n/a | yes |
16+
| project\_id | The ID of the project in which to provision network. | `string` | n/a | yes |
17+
18+
## Outputs
19+
20+
| Name | Description |
21+
|------|-------------|
22+
| access\_level | n/a |
23+
24+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/access_level_vpc_ip/main.tf

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
resource "random_id" "random_suffix" {
18+
byte_length = 2
19+
}
20+
21+
module "access_context_manager_policy" {
22+
source = "terraform-google-modules/vpc-service-controls/google"
23+
version = "~> 5.0"
24+
25+
parent_id = var.parent_id
26+
policy_name = "int_test_vpc_sc_policy_${random_id.random_suffix.hex}"
27+
}
28+
29+
#Create Network with a subnetwork and private service access for both netapp.servicenetworking.goog and servicenetworking.googleapis.com
30+
31+
resource "google_compute_network" "network1" {
32+
name = "vpc-a"
33+
project = var.project_id
34+
auto_create_subnetworks = false
35+
description = "test network"
36+
}
37+
38+
resource "google_compute_subnetwork" "network1_us_central1" {
39+
name = "vpc-a-us-central1"
40+
ip_cidr_range = "10.0.0.0/24"
41+
region = "us-central1"
42+
project = var.project_id
43+
network = google_compute_network.network1.self_link
44+
private_ip_google_access = true
45+
}
46+
47+
resource "google_compute_subnetwork" "network1_us_east1" {
48+
name = "vpc-a-us-east1"
49+
ip_cidr_range = "10.0.1.0/24"
50+
region = "us-east1"
51+
project = var.project_id
52+
network = google_compute_network.network1.self_link
53+
private_ip_google_access = true
54+
}
55+
56+
resource "google_compute_network" "network2" {
57+
name = "vpc-b"
58+
project = var.project_id
59+
auto_create_subnetworks = false
60+
description = "test network b"
61+
}
62+
63+
resource "google_compute_subnetwork" "network2_us_central1" {
64+
name = "vpc-b-us-central1"
65+
ip_cidr_range = "10.0.10.0/24"
66+
region = "us-central1"
67+
project = var.project_id
68+
network = google_compute_network.network2.self_link
69+
private_ip_google_access = true
70+
}
71+
72+
module "access_level_vpc_ranges" {
73+
source = "terraform-google-modules/vpc-service-controls/google//modules/access_level"
74+
version = "~> 5.0"
75+
76+
policy = module.access_context_manager_policy.policy_id
77+
name = "vpc_ip_address_policy"
78+
description = "access level for vpc ip addresses"
79+
vpc_network_sources = {
80+
"vpc_a" = {
81+
network_id = google_compute_network.network1.id
82+
ip_address_ranges = [
83+
"10.0.0.0/24",
84+
"192.169.0.0/16",
85+
]
86+
}
87+
"vpc_b" = {
88+
network_id = google_compute_network.network2.id
89+
}
90+
}
91+
depends_on = [
92+
google_compute_subnetwork.network1_us_central1,
93+
google_compute_subnetwork.network1_us_east1,
94+
google_compute_subnetwork.network2_us_central1,
95+
]
96+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "access_level" {
18+
value = module.access_level_vpc_ranges.access_level
19+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Copyright 2024 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "parent_id" {
18+
description = "The parent of this AccessPolicy in the Cloud Resource Hierarchy. As of now, only organization are accepted as parent."
19+
type = string
20+
}
21+
22+
variable "project_id" {
23+
description = "The ID of the project in which to provision network."
24+
type = string
25+
}

examples/automatic_folder/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

examples/automatic_folder/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

examples/automatic_folder/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2019 Google LLC
2+
* Copyright 2024 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)