Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: deletion_policy PREVENT as default #940

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ determining that location is as follows:
| create\_project\_sa | Whether the default service account for the project shall be created | `bool` | `true` | no |
| 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 |
| default\_service\_account | Project default service account setting: can be one of `delete`, `deprivilege`, `disable`, or `keep`. | `string` | `"disable"` | no |
| deletion\_policy | The deletion policy for the project. | `string` | `null` | no |
| deletion\_policy | The deletion policy for the project. | `string` | `"PREVENT"` | no |
| 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 |
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |
| domain | The domain name (optional). | `string` | `""` | no |
Expand Down
20 changes: 20 additions & 0 deletions docs/upgrading_to_project_factory_v17.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Upgrading to Project Factory v17.0

The v17.0 release of Project Factory is a backwards incompatible release.

### Google Cloud Provider Project deletion_policy

The `deletion_policy` for projects now defaults to `"PREVENT"` rather than `"DELETE"`. This aligns with the behavior in Google Cloud Platform Provider v6+. To maintain the old behavior you can set `deletion_policy = "DELETE"`.

```diff
module "project" {
- version = "~> 16.0"
+ version = "~> 17.0"

+ deletion_policy = "DELETE"
}
```

### Google Cloud Platform Provider upgrade

The Project Factory module now requires version `5.41` or higher of the Google Cloud Platform Provider and `5.41` or higher of the Google Cloud Platform Beta Provider.
2 changes: 2 additions & 0 deletions examples/app_engine/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module "app-engine-project" {
activate_apis = [
"appengine.googleapis.com",
]

deletion_policy = "DELETE"
}

module "app-engine" {
Expand Down
1 change: 1 addition & 0 deletions examples/budget_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module "budget_project" {
"billingbudgets.googleapis.com"
]

deletion_policy = "DELETE"
}


Expand Down
2 changes: 2 additions & 0 deletions examples/essential_contacts/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ module "project-factory" {

default_service_account = "DISABLE"
disable_services_on_destroy = false

deletion_policy = "DELETE"
}
2 changes: 2 additions & 0 deletions examples/fabric_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ module "fabric-project" {
owners = var.owners
parent = var.parent
prefix = local.prefix

deletion_policy = "DELETE"
}
2 changes: 2 additions & 0 deletions examples/gke_shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ module "project-factory" {
activate_apis = ["compute.googleapis.com", "container.googleapis.com", "cloudbilling.googleapis.com"]
shared_vpc_subnets = var.shared_vpc_subnets
default_network_tier = var.default_network_tier

deletion_policy = "DELETE"
}
2 changes: 2 additions & 0 deletions examples/quota_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,6 @@ module "quota-project" {
value = "95"
}
]

deletion_policy = "DELETE"
}
4 changes: 4 additions & 0 deletions examples/shared_vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "host-project" {
"cloudresourcemanager.googleapis.com"
]

deletion_policy = "DELETE"
}

/******************************************
Expand Down Expand Up @@ -113,6 +114,7 @@ module "service-project" {
]

disable_services_on_destroy = false
deletion_policy = "DELETE"
}

/******************************************
Expand Down Expand Up @@ -146,6 +148,7 @@ module "service-project-b" {
}]

disable_services_on_destroy = false
deletion_policy = "DELETE"
}

/******************************************
Expand Down Expand Up @@ -184,6 +187,7 @@ module "service-project-c" {

disable_services_on_destroy = false
grant_network_role = false
deletion_policy = "DELETE"
}

/******************************************
Expand Down
2 changes: 2 additions & 0 deletions examples/simple_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ module "project-factory" {
"roles/bigquery.jobUser",
]
}]

deletion_policy = "DELETE"
}
2 changes: 2 additions & 0 deletions examples/tags_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ module "project-factory" {
billing_account = var.billing_account
default_service_account = "deprivilege"
tag_binding_values = [var.tag_value]

deletion_policy = "DELETE"
}
2 changes: 1 addition & 1 deletion modules/core_project_factory/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,5 @@ variable "cloud_armor_tier" {
variable "deletion_policy" {
description = "The deletion policy for the project."
type = string
default = null
default = "PREVENT"
}
2 changes: 1 addition & 1 deletion modules/fabric-project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module "project_myproject" {
| auto\_create\_network | Whether to create the default network for the project | `bool` | `false` | no |
| billing\_account | Billing account id. | `string` | `""` | no |
| custom\_roles | Map of role name => comma-delimited list of permissions to create in this project. | `map(string)` | `{}` | no |
| deletion\_policy | The deletion policy for the project. | `string` | `null` | no |
| deletion\_policy | The deletion policy for the project. | `string` | `"PREVENT"` | no |
| editors | Optional list of IAM-format members to set as project editor. | `list(string)` | `[]` | no |
| extra\_bindings\_members | List of comma-delimited IAM-format members for additional IAM bindings, one item per role. | `list(string)` | `[]` | no |
| extra\_bindings\_roles | List of roles for additional IAM bindings, pair with members list below. | `list(string)` | `[]` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/fabric-project/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,5 @@ variable "labels" {
variable "deletion_policy" {
description = "The deletion policy for the project."
type = string
default = null
default = "PREVENT"
}
1 change: 1 addition & 0 deletions modules/svpc_service_project/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module "service-project" {
| create\_project\_sa | Whether the default service account for the project shall be created | `bool` | `true` | no |
| 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 |
| default\_service\_account | Project default service account setting: can be one of `delete`, `deprivilege`, `disable`, or `keep`. | `string` | `"disable"` | no |
| deletion\_policy | The deletion policy for the project. | `string` | `"PREVENT"` | no |
| 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 |
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |
| domain | The domain name (optional). | `string` | `""` | no |
Expand Down
1 change: 1 addition & 0 deletions modules/svpc_service_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module "project-factory" {
default_service_account = var.default_service_account
disable_dependent_services = var.disable_dependent_services
default_network_tier = var.default_network_tier
deletion_policy = var.deletion_policy
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/svpc_service_project/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,9 @@ variable "default_network_tier" {
type = string
default = ""
}

variable "deletion_policy" {
description = "The deletion policy for the project."
type = string
default = "PREVENT"
}
2 changes: 2 additions & 0 deletions test/fixtures/minimal/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ module "project-factory" {

default_service_account = "DISABLE"
disable_services_on_destroy = false

deletion_policy = "DELETE"
}

// Add a binding to the container service robot account to test that the
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/vpc_sc_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module "project-factory" {

vpc_service_control_attach_enabled = true
vpc_service_control_perimeter_name = "accessPolicies/${var.policy_id}/servicePerimeters/${local.perimeter_name}"

deletion_policy = "DELETE"
}

resource "google_project_iam_member" "iam-binding" {
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,5 @@ variable "cloud_armor_tier" {
variable "deletion_policy" {
description = "The deletion policy for the project."
type = string
default = null
default = "PREVENT"
}
Loading