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(deps)!: Update Terraform Google Provider to v6 #320

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ff93f1b
feat(deps): Update Terraform Google Provider to v6
daniel-cit Oct 14, 2024
911f5f7
update project_services module to v17.0
daniel-cit Oct 15, 2024
9f95e76
Merge branch 'master' into major-terraform-google-provider-v6
apeabody Oct 15, 2024
c84ebd6
update module simple_bucket version to v7.0
daniel-cit Oct 16, 2024
2fd41b2
update simple_bucket,kms, and project-factory
daniel-cit Oct 23, 2024
1893361
add time sleep for IAM propagation
daniel-cit Oct 24, 2024
d2dfec0
add time provider version constraint
daniel-cit Oct 24, 2024
c2b8ce9
grant connection viewer role to cloud build SA
daniel-cit Oct 24, 2024
ee6523f
remove role cloudbuild.connectionViewer
daniel-cit Oct 24, 2024
120090b
add wait propagation after connection creation
daniel-cit Oct 24, 2024
f1609b4
add role cloudbuild.connectionAdmin to CB SA
daniel-cit Oct 24, 2024
4326368
grant cloudbuild.serviceAgent to the cloudbuid service agent SA
daniel-cit Oct 25, 2024
ff9e58b
grant additional role in test setup
daniel-cit Oct 25, 2024
3472e78
revert extra changes
daniel-cit Oct 25, 2024
19ea1ee
grant service agent role in test setup
daniel-cit Oct 25, 2024
d6bab85
grant service agent role in test setup to service agent SA
daniel-cit Oct 25, 2024
b8d5fd9
configure deletion_policy in project-factory
daniel-cit Oct 25, 2024
4b16964
lint fixes
daniel-cit Oct 25, 2024
fd705e6
set project deletion_policy to DELETE
daniel-cit Oct 25, 2024
ca2a564
add missing variables
daniel-cit Oct 25, 2024
9f1353b
increase integration build timeout to 90 minutes
daniel-cit Oct 25, 2024
d2e2b3f
create Cloud Workflows Service Agent in test setup
daniel-cit Oct 28, 2024
bab4ed5
update upgrading to v9 instructions
daniel-cit Oct 28, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ For the cloudbuild submodule, see the README [cloudbuild](./modules/cloudbuild).
| org\_id | GCP Organization ID | `string` | n/a | yes |
| org\_project\_creators | Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required. | `list(string)` | `[]` | no |
| parent\_folder | GCP parent folder ID in the form folders/{id} | `string` | `""` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| project\_id | Custom project ID to use for project created. If not supplied, the default id is {project\_prefix}-seed-{random suffix}. | `string` | `""` | no |
| project\_labels | Labels to apply to the project. | `map(string)` | `{}` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"cft"` | no |
Expand Down
2 changes: 1 addition & 1 deletion build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

timeout: 4200s
timeout: 5400s
steps:
- id: swap-module-refs
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
Expand Down
40 changes: 40 additions & 0 deletions docs/upgrading_to_v9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,43 @@ The endpoint that is used to trigger a build was replaced with a new one that al
```
# module.cloudbuilder.google_workflows_workflow.builder will be updated in-place
```

## Google Cloud Provider Project deletion_policy

The `deletion_policy` for [project-factory](https://github.com/terraform-google-modules/terraform-google-project-factory) module now defaults to `"PREVENT"` rather than `"DELETE"`.
This aligns with the behavior in Google Cloud Platform Provider v6+.
To maintain the old behavior in the projects created within the modules you can set the new variable `project_deletion_policy = "DELETE"`.

### Bootstrap main module

```diff
module "bootstrap" {
source = "terraform-google-modules/bootstrap/google"
- version = "~> 8.0"
+ version = "~> 9.0"

+ project_deletion_policy = "DELETE"
```

### Cloud Build sub module

```diff
module "cloudbuild" {
source = "terraform-google-modules/bootstrap/google//modules/cloudbuild"
- version = "~> 8.0"
+ version = "~> 9.0"

+ project_deletion_policy = "DELETE"
```


### Cloud Build Source sub module

```diff
module "tf_cloudbuild_source" {
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_source"
- version = "~> 8.0"
+ version = "~> 9.0"

+ project_deletion_policy = "DELETE"
```
1 change: 1 addition & 0 deletions examples/cloudbuild_enabled/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This example combines the Organization bootstrap module with the Cloud Build sub
| group\_org\_admins | Google Group for GCP Organization Administrators | `string` | n/a | yes |
| org\_id | GCP Organization ID | `string` | n/a | yes |
| org\_project\_creators | Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required. | `list(string)` | `[]` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"cft"` | no |

## Outputs
Expand Down
2 changes: 2 additions & 0 deletions examples/cloudbuild_enabled/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module "seed_bootstrap" {
sa_enable_impersonation = true
project_prefix = var.project_prefix
force_destroy = var.force_destroy
project_deletion_policy = var.project_deletion_policy
}

module "cloudbuild_bootstrap" {
Expand All @@ -47,4 +48,5 @@ module "cloudbuild_bootstrap" {
terraform_state_bucket = module.seed_bootstrap.gcs_bucket_tfstate
project_prefix = var.project_prefix
force_destroy = var.force_destroy
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions examples/cloudbuild_enabled/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ variable "force_destroy" {
type = bool
default = false
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
2 changes: 1 addition & 1 deletion examples/cloudbuild_repo_connection_github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

module "github_connection" {
source = "terraform-google-modules/bootstrap/google//modules/cloudbuild_repo_connection"
source = "terraform-google-modules/bootstrap/google//modules/cloudbuild_repo_connection"
version = "~> 9.0"

project_id = var.project_id
Expand Down
2 changes: 1 addition & 1 deletion examples/im_cloudbuild_workspace_github/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 1 addition & 1 deletion examples/im_cloudbuild_workspace_gitlab/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
1 change: 1 addition & 0 deletions examples/simple-folder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This example demonstrates the simplest usage of the GCP organization bootstrap m
| org\_id | GCP Organization ID | `string` | n/a | yes |
| org\_project\_creators | Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required. | `list(string)` | `[]` | no |
| parent | GCP parent folder id of form folders/{id} | `string` | n/a | yes |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"cft"` | no |

## Outputs
Expand Down
17 changes: 9 additions & 8 deletions examples/simple-folder/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ module "seed_bootstrap" {
source = "terraform-google-modules/bootstrap/google"
version = "~> 8.0"

org_id = var.org_id
parent_folder = var.parent
billing_account = var.billing_account
group_org_admins = var.group_org_admins
group_billing_admins = var.group_billing_admins
default_region = var.default_region
org_project_creators = var.org_project_creators
project_prefix = var.project_prefix
org_id = var.org_id
parent_folder = var.parent
billing_account = var.billing_account
group_org_admins = var.group_org_admins
group_billing_admins = var.group_billing_admins
default_region = var.default_region
org_project_creators = var.org_project_creators
project_prefix = var.project_prefix
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions examples/simple-folder/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ variable "project_prefix" {
default = "cft"
type = string
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
1 change: 1 addition & 0 deletions examples/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This example demonstrates the simplest usage of the GCP organization bootstrap m
| group\_org\_admins | Google Group for GCP Organization Administrators | `string` | n/a | yes |
| org\_id | GCP Organization ID | `string` | n/a | yes |
| org\_project\_creators | Additional list of members to have project creator role accross the organization. Prefix of group: user: or serviceAccount: is required. | `list(string)` | `[]` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"cft"` | no |

## Outputs
Expand Down
15 changes: 8 additions & 7 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ module "seed_bootstrap" {
source = "terraform-google-modules/bootstrap/google"
version = "~> 8.0"

org_id = var.org_id
billing_account = var.billing_account
group_org_admins = var.group_org_admins
group_billing_admins = var.group_billing_admins
default_region = var.default_region
org_project_creators = var.org_project_creators
project_prefix = var.project_prefix
org_id = var.org_id
billing_account = var.billing_account
group_org_admins = var.group_org_admins
group_billing_admins = var.group_billing_admins
default_region = var.default_region
org_project_creators = var.org_project_creators
project_prefix = var.project_prefix
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions examples/simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ variable "project_prefix" {
default = "cft"
type = string
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_builder_simple/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_builder_simple_github/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_builder_simple_gitlab/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 2 additions & 0 deletions examples/tf_cloudbuild_builder_simple_gitlab/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ module "cloudbuilder" {

# allow logs bucket to be destroyed
cb_logs_bucket_force_destroy = true

depends_on = [module.enabled_google_apis]
}

// Create a secret containing the personal access token and grant permissions to the Service Agent.
Expand Down
1 change: 1 addition & 0 deletions examples/tf_cloudbuild_source_simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This example demonstrates the simplest usage of the [tf_cloudbuild_source](../..
| group\_org\_admins | Google Group for GCP Organization Administrators | `string` | n/a | yes |
| org\_id | GCP Organization ID | `string` | n/a | yes |
| parent\_folder | The bootstrap parent folder | `string` | `""` | no |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |

## Outputs

Expand Down
11 changes: 6 additions & 5 deletions examples/tf_cloudbuild_source_simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ module "tf_source" {
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_source"
version = "~> 8.0"

org_id = var.org_id
folder_id = var.parent_folder
billing_account = var.billing_account
group_org_admins = var.group_org_admins
buckets_force_destroy = true
org_id = var.org_id
folder_id = var.parent_folder
billing_account = var.billing_account
group_org_admins = var.group_org_admins
buckets_force_destroy = true
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions examples/tf_cloudbuild_source_simple/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,9 @@ variable "group_org_admins" {
description = "Google Group for GCP Organization Administrators"
type = string
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_workspace_simple/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_workspace_simple_github/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
1 change: 0 additions & 1 deletion examples/tf_cloudbuild_workspace_simple_github/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ module "tf_workspace" {
depends_on = [module.enabled_google_apis]
}


// Create a secret containing the personal access token and grant permissions to the Service Agent.
resource "google_secret_manager_secret" "github_token_secret" {
project = var.project_id
Expand Down
2 changes: 1 addition & 1 deletion examples/tf_cloudbuild_workspace_simple_gitlab/apis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

module "enabled_google_apis" {
source = "terraform-google-modules/project-factory/google//modules/project_services"
version = "~> 15.0"
version = "~> 17.0"

project_id = var.project_id
disable_services_on_destroy = false
Expand Down
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "google_folder_iam_member" "tmp_project_creator" {

module "seed_project" {
source = "terraform-google-modules/project-factory/google"
version = "~> 15.0"
version = "~> 17.0"
name = local.seed_project_id
random_project_id = var.random_suffix
disable_services_on_destroy = false
Expand All @@ -70,6 +70,7 @@ module "seed_project" {
create_project_sa = false
labels = var.project_labels
lien = true
deletion_policy = var.project_deletion_policy
}

module "enable_cross_project_service_account_usage" {
Expand Down Expand Up @@ -111,7 +112,7 @@ data "google_storage_project_service_account" "gcs_account" {
module "kms" {
count = var.encrypt_gcs_bucket_tfstate ? 1 : 0
source = "terraform-google-modules/kms/google"
version = "~> 2.1"
version = "~> 3.2"

project_id = module.seed_project.project_id
location = var.default_region
Expand Down
1 change: 1 addition & 0 deletions modules/cloudbuild/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Functional examples and sample Cloud Build definitions are included in the [exam
| group\_org\_admins | Google Group for GCP Organization Administrators | `string` | n/a | yes |
| impersonate\_service\_account | The service account to impersonate while running the gcloud builds submit command. | `string` | `""` | no |
| org\_id | GCP Organization ID | `string` | n/a | yes |
| project\_deletion\_policy | The deletion policy for the project created. | `string` | `"PREVENT"` | no |
| project\_id | Custom project ID to use for project created. | `string` | `""` | no |
| project\_labels | Labels to apply to the project. | `map(string)` | `{}` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"cft"` | no |
Expand Down
3 changes: 2 additions & 1 deletion modules/cloudbuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ resource "random_id" "suffix" {

module "cloudbuild_project" {
source = "terraform-google-modules/project-factory/google"
version = "~> 15.0"
version = "~> 17.0"
name = local.cloudbuild_project_id
random_project_id = var.random_suffix
disable_services_on_destroy = false
Expand All @@ -45,6 +45,7 @@ module "cloudbuild_project" {
billing_account = var.billing_account
activate_apis = local.activate_apis
labels = var.project_labels
deletion_policy = var.project_deletion_policy
}

/******************************************
Expand Down
6 changes: 6 additions & 0 deletions modules/cloudbuild/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ variable "project_id" {
type = string
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}

variable "activate_apis" {
description = "List of APIs to enable in the Cloudbuild project."
type = list(string)
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudbuild/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ terraform {
google = {
source = "hashicorp/google"
# Exclude 4.31.0 for https://github.com/hashicorp/terraform-provider-google/issues/12226
version = ">= 3.50, != 4.31.0, <6"
version = ">= 3.50, != 4.31.0, <7"
}
google-beta = {
source = "hashicorp/google-beta"
# Exclude 4.31.0 for https://github.com/hashicorp/terraform-provider-google/issues/12226
version = ">= 3.50, != 4.31.0, <6"
version = ">= 3.50, != 4.31.0, <7"
}
random = {
source = "hashicorp/random"
Expand Down
4 changes: 2 additions & 2 deletions modules/cloudbuild_repo_connection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ terraform {
google = {
source = "hashicorp/google"
# Exclude 4.31.0 for https://github.com/hashicorp/terraform-provider-google/issues/12226
version = ">= 4.17, != 4.31.0, < 6"
version = ">= 4.17, != 4.31.0, < 7"
}

time = {
Expand All @@ -37,7 +37,7 @@ terraform {
google-beta = {
source = "hashicorp/google-beta"
# Exclude 4.31.0 for https://github.com/hashicorp/terraform-provider-google/issues/12226
version = ">= 4.17, != 4.31.0, < 6"
version = ">= 4.17, != 4.31.0, < 7"
}
}
}
Loading