Skip to content

Commit f5cce9e

Browse files
authored
feat: add network service tier setting (#640)
* feat: add network service tier setting This allows users to configure the project default Network Service Tier. * run docker_generate_docs * code review fixes * re-generate docs * terraform fmt * add blank line
1 parent dd9beb3 commit f5cce9e

File tree

17 files changed

+57
-3
lines changed

17 files changed

+57
-3
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ determining that location is as follows:
114114
| auto\_create\_network | Create the default network | `bool` | `false` | no |
115115
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
116116
| bucket\_force\_destroy | Force the deletion of all objects within the GCS bucket when deleting the bucket (optional) | `bool` | `false` | no |
117-
| bucket\_labels | A map of key/value label pairs to assign to the bucket (optional) | `map` | `{}` | no |
117+
| bucket\_labels | A map of key/value label pairs to assign to the bucket (optional) | `map(string)` | `{}` | no |
118118
| bucket\_location | The location for a GCS bucket to create (optional) | `string` | `"US"` | no |
119119
| bucket\_name | A name for a GCS bucket to create (in the bucket\_project project), useful for Terraform state (optional) | `string` | `""` | no |
120120
| bucket\_project | A project to create a GCS bucket (bucket\_name) in, useful for Terraform state (optional) | `string` | `""` | no |
@@ -127,6 +127,7 @@ determining that location is as follows:
127127
| budget\_monitoring\_notification\_channels | A list of monitoring notification channels in the form `[projects/{project_id}/notificationChannels/{channel_id}]`. A maximum of 5 channels are allowed. | `list(string)` | `[]` | no |
128128
| consumer\_quotas | The quotas configuration you want to override for the project. | <pre>list(object({<br> service = string,<br> metric = string,<br> limit = string,<br> value = string,<br> }))</pre> | `[]` | no |
129129
| create\_project\_sa | Whether the default service account for the project shall be created | `bool` | `true` | no |
130+
| default\_network\_tier | Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers. | `string` | `""` | no |
130131
| default\_service\_account | Project default service account setting: can be one of `delete`, `deprivilege`, `disable`, or `keep`. | `string` | `"disable"` | no |
131132
| disable\_dependent\_services | Whether services that are enabled and which depend on this service should also be disabled when this service is destroyed. | `bool` | `true` | no |
132133
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |

examples/gke_shared_vpc/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ More information about GKE with Shared VPC can be found here: https://cloud.goog
2929
| Name | Description | Type | Default | Required |
3030
|------|-------------|------|---------|:--------:|
3131
| billing\_account | billing account | `any` | n/a | yes |
32+
| default\_network\_tier | Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers. | `string` | `""` | no |
3233
| org\_id | organization id | `any` | n/a | yes |
3334
| shared\_vpc | The ID of the host project which hosts the shared VPC | `any` | n/a | yes |
3435
| shared\_vpc\_subnets | List of subnets fully qualified subnet IDs (ie. projects/$PROJECT\_ID/regions/$REGION/subnetworks/$SUBNET\_ID) | `list(string)` | `[]` | no |

examples/gke_shared_vpc/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ module "project-factory" {
2323
svpc_host_project_id = var.shared_vpc
2424
activate_apis = ["compute.googleapis.com", "container.googleapis.com", "cloudbilling.googleapis.com"]
2525
shared_vpc_subnets = var.shared_vpc_subnets
26+
default_network_tier = var.default_network_tier
2627
}

examples/gke_shared_vpc/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ variable "shared_vpc_subnets" {
3232
default = []
3333
}
3434

35+
variable "default_network_tier" {
36+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
37+
type = string
38+
default = ""
39+
}

examples/shared_vpc/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ It then attaches two new service projects to the host project.
1212
| Name | Description | Type | Default | Required |
1313
|------|-------------|------|---------|:--------:|
1414
| billing\_account | The ID of the billing account to associate this project with | `any` | n/a | yes |
15+
| default\_network\_tier | Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers. | `string` | `""` | no |
1516
| folder\_id | The folder to create projects in | `any` | n/a | yes |
1617
| host\_project\_name | Name for Shared VPC host project | `string` | `"shared-vpc-host"` | no |
1718
| network\_name | Name for Shared VPC network | `string` | `"shared-network"` | no |

examples/shared_vpc/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module "host-project" {
3030
folder_id = var.folder_id
3131
billing_account = var.billing_account
3232
enable_shared_vpc_host_project = true
33+
default_network_tier = var.default_network_tier
3334
}
3435

3536
/******************************************

examples/shared_vpc/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ variable "network_name" {
4040
description = "Name for Shared VPC network"
4141
default = "shared-network"
4242
}
43+
44+
variable "default_network_tier" {
45+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
46+
type = string
47+
default = ""
48+
}

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module "project-factory" {
6363
disable_dependent_services = var.disable_dependent_services
6464
vpc_service_control_attach_enabled = var.vpc_service_control_attach_enabled
6565
vpc_service_control_perimeter_name = var.vpc_service_control_perimeter_name
66+
default_network_tier = var.default_network_tier
6667
}
6768

6869
/******************************************

modules/core_project_factory/main.tf

+9
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,12 @@ resource "google_project_service" "enable_access_context_manager" {
350350
project = google_project.main.number
351351
service = "accesscontextmanager.googleapis.com"
352352
}
353+
354+
/******************************************
355+
Configure default Network Service Tier
356+
*****************************************/
357+
resource "google_compute_project_default_network_tier" "default" {
358+
count = var.default_network_tier != "" ? 1 : 0
359+
project = google_project.main.number
360+
network_tier = var.default_network_tier
361+
}

modules/core_project_factory/variables.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ variable "bucket_versioning" {
165165

166166
variable "bucket_labels" {
167167
description = " A map of key/value label pairs to assign to the bucket (optional)"
168-
type = map
168+
type = map(string)
169169
default = {}
170170
}
171171

@@ -227,3 +227,9 @@ variable "vpc_service_control_perimeter_name" {
227227
type = string
228228
default = null
229229
}
230+
231+
variable "default_network_tier" {
232+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
233+
type = string
234+
default = ""
235+
}

modules/gsuite_enabled/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ The roles granted are specifically:
7272
| consumer\_quotas | The quotas configuration you want to override for the project. | <pre>list(object({<br> service = string,<br> metric = string,<br> limit = string,<br> value = string,<br> }))</pre> | `[]` | no |
7373
| create\_group | Whether to create the group or not | `bool` | `false` | no |
7474
| create\_project\_sa | Whether the default service account for the project shall be created | `bool` | `true` | no |
75+
| default\_network\_tier | Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers. | `string` | `""` | no |
7576
| default\_service\_account | Project default service account setting: can be one of `delete`, `deprivilege`, `disable`, or `keep`. | `string` | `"disable"` | no |
7677
| disable\_dependent\_services | Whether services that are enabled and which depend on this service should also be disabled when this service is destroyed. | `bool` | `true` | no |
7778
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |

modules/gsuite_enabled/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ module "project-factory" {
9999
disable_services_on_destroy = var.disable_services_on_destroy
100100
default_service_account = var.default_service_account
101101
disable_dependent_services = var.disable_dependent_services
102+
default_network_tier = var.default_network_tier
102103
}
103104

104105
/******************************************

modules/gsuite_enabled/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,9 @@ variable "consumer_quotas" {
220220
}))
221221
default = []
222222
}
223+
224+
variable "default_network_tier" {
225+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
226+
type = string
227+
default = ""
228+
}

modules/svpc_service_project/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ module "service-project" {
4444
| budget\_amount | The amount to use for a budget alert | `number` | `null` | no |
4545
| budget\_monitoring\_notification\_channels | A list of monitoring notification channels in the form `[projects/{project_id}/notificationChannels/{channel_id}]`. A maximum of 5 channels are allowed. | `list(string)` | `[]` | no |
4646
| create\_project\_sa | Whether the default service account for the project shall be created | `bool` | `true` | no |
47+
| default\_network\_tier | Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers. | `string` | `""` | no |
4748
| default\_service\_account | Project default service account setting: can be one of `delete`, `deprivilege`, `disable`, or `keep`. | `string` | `"disable"` | no |
4849
| disable\_dependent\_services | Whether services that are enabled and which depend on this service should also be disabled when this service is destroyed. | `bool` | `true` | no |
4950
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |

modules/svpc_service_project/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module "project-factory" {
5757
disable_services_on_destroy = var.disable_services_on_destroy
5858
default_service_account = var.default_service_account
5959
disable_dependent_services = var.disable_dependent_services
60+
default_network_tier = var.default_network_tier
6061
}
6162

6263
/******************************************

modules/svpc_service_project/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,9 @@ variable "grant_services_network_role" {
221221
type = bool
222222
default = true
223223
}
224+
225+
variable "default_network_tier" {
226+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
227+
type = string
228+
default = ""
229+
}

variables.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ variable "bucket_versioning" {
165165

166166
variable "bucket_labels" {
167167
description = " A map of key/value label pairs to assign to the bucket (optional)"
168-
type = map
168+
type = map(string)
169169
default = {}
170170
}
171171

@@ -275,3 +275,9 @@ variable "consumer_quotas" {
275275
}))
276276
default = []
277277
}
278+
279+
variable "default_network_tier" {
280+
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
281+
type = string
282+
default = ""
283+
}

0 commit comments

Comments
 (0)