Skip to content

Commit 8c1512a

Browse files
committed
feat: add svpc deletion policy
1 parent 9ac04a6 commit 8c1512a

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ determining that location is as follows:
157157
| random\_project\_id\_length | Sets the length of `random_project_id` to the provided length, and uses a `random_string` for a larger collusion domain. Recommended for use with CI. | `number` | `null` | no |
158158
| sa\_role | A role to give the default Service Account for the project (defaults to none) | `string` | `""` | no |
159159
| shared\_vpc\_subnets | List of subnets fully qualified subnet IDs (ie. projects/$project\_id/regions/$region/subnetworks/$subnet\_id) | `list(string)` | `[]` | no |
160+
| svpc\_deletion\_policy | The deletion policy for the service project shared VPC. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: null, "ABANDON". | `string` | `null` | no |
160161
| svpc\_host\_project\_id | The ID of the host project which hosts the shared VPC | `string` | `""` | no |
161162
| tag\_binding\_values | Tag values to bind the project to. | `list(string)` | `[]` | no |
162163
| usage\_bucket\_name | Name of a GCS bucket to store GCE usage reports in (optional) | `string` | `""` | no |

main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module "project-factory" {
3939
project_id = var.project_id
4040
shared_vpc = var.svpc_host_project_id
4141
enable_shared_vpc_service_project = var.svpc_host_project_id != ""
42+
shared_vpc_deletion_policy = var.svpc_deletion_policy
4243
enable_shared_vpc_host_project = var.enable_shared_vpc_host_project
4344
grant_network_role = var.grant_network_role
4445
billing_account = var.billing_account

modules/core_project_factory/main.tf

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ resource "google_compute_shared_vpc_service_project" "shared_vpc_attachment" {
121121
host_project = var.shared_vpc
122122
service_project = google_project.main.project_id
123123
depends_on = [time_sleep.wait_5_seconds[0], module.project_services]
124+
deletion_policy = var.shared_vpc_deletion_policy
124125
}
125126

126127
resource "google_compute_shared_vpc_host_project" "shared_vpc_host" {

modules/core_project_factory/variables.tf

+11
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ variable "enable_shared_vpc_service_project" {
223223
type = bool
224224
}
225225

226+
variable "shared_vpc_deletion_policy" {
227+
description = "The deletion policy for the service project shared VPC. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: null, \"ABANDON\"."
228+
type = string
229+
default = null
230+
231+
validation {
232+
condition = (var.shared_vpc_deletion_policy == null || var.shared_vpc_deletion_policy == "ABANDON")
233+
error_message = "The shared_vpc_deletion_policy value must be null or \"ABANDON\"."
234+
}
235+
}
236+
226237
variable "enable_shared_vpc_host_project" {
227238
description = "If this project is a shared VPC host project. If true, you must *not* set shared_vpc variable. Default is false."
228239
type = bool

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ variable "svpc_host_project_id" {
5555
default = ""
5656
}
5757

58+
variable "svpc_deletion_policy" {
59+
description = "The deletion policy for the service project shared VPC. Setting ABANDON allows the resource to be abandoned rather than deleted. Possible values are: null, \"ABANDON\"."
60+
type = string
61+
default = null
62+
}
63+
5864
variable "enable_shared_vpc_host_project" {
5965
description = "If this project is a shared VPC host project. If true, you must *not* set svpc_host_project_id variable. Default is false."
6066
type = bool

0 commit comments

Comments
 (0)