Skip to content

Commit

Permalink
upgrade bootstrap and project-factory modules
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-cit committed Nov 1, 2024
1 parent ecdd8f2 commit ebaf7dd
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 25 deletions.
9 changes: 6 additions & 3 deletions 0-bootstrap/cb.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module "gcp_projects_state_bucket" {

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

org_id = var.org_id
folder_id = google_folder.bootstrap.id
Expand All @@ -96,6 +96,9 @@ module "tf_source" {
group_org_admins = var.groups.required_groups.group_org_admins
buckets_force_destroy = var.bucket_force_destroy

project_deletion_policy = var.project_deletion_policy


activate_apis = [
"serviceusage.googleapis.com",
"servicenetworking.googleapis.com",
Expand Down Expand Up @@ -155,7 +158,7 @@ module "tf_private_pool" {

module "tf_cloud_builder" {
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_builder"
version = "~> 8.0"
version = "~> 9.0"

project_id = module.tf_source.cloudbuild_project_id
dockerfile_repo_uri = module.tf_source.csr_repos[local.cloudbuilder_repo].url
Expand Down Expand Up @@ -206,7 +209,7 @@ module "build_terraform_image" {

module "tf_workspace" {
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_workspace"
version = "~> 8.0"
version = "~> 9.0"
for_each = local.granular_sa

project_id = module.tf_source.cloudbuild_project_id
Expand Down
4 changes: 3 additions & 1 deletion 0-bootstrap/github.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ locals {

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

name = "${var.project_prefix}-b-cicd-wif-gh"
random_project_id = true
Expand All @@ -87,6 +87,8 @@ module "gh_cicd" {
"cloudresourcemanager.googleapis.com",
"iamcredentials.googleapis.com",
]

deletion_policy = var.project_deletion_policy
}

module "gh_oidc" {
Expand Down
5 changes: 3 additions & 2 deletions 0-bootstrap/gitlab.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ provider "gitlab" {

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

name = "${var.project_prefix}-b-cicd-wif-gl"
random_project_id = true
Expand All @@ -100,8 +100,9 @@ module "gitlab_cicd" {
"sts.googleapis.com",
"dns.googleapis.com",
"secretmanager.googleapis.com",

]

deletion_policy = var.project_deletion_policy
}

module "gitlab_oidc" {
Expand Down
1 change: 1 addition & 0 deletions 0-bootstrap/jenkins.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module "jenkins_bootstrap" {
tunnel0_bgp_session_range = var.tunnel0_bgp_session_range
tunnel1_bgp_peer_address = var.tunnel1_bgp_peer_address
tunnel1_bgp_session_range = var.tunnel1_bgp_session_range
project_deletion_policy = var.project_deletion_policy
}

resource "google_organization_iam_member" "org_jenkins_sa_browser" {
Expand Down
3 changes: 2 additions & 1 deletion 0-bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ resource "google_folder" "bootstrap" {

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

org_id = var.org_id
folder_id = google_folder.bootstrap.id
Expand All @@ -61,6 +61,7 @@ module "seed_bootstrap" {
encrypt_gcs_bucket_tfstate = true
key_rotation_period = "7776000s"
kms_prevent_destroy = !var.bucket_tfstate_kms_force_destroy
project_deletion_policy = var.project_deletion_policy

project_labels = {
environment = "bootstrap"
Expand Down
4 changes: 3 additions & 1 deletion 0-bootstrap/modules/jenkins-agent/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "random_id" "suffix" {
*******************************************/
module "cicd_project" {
source = "terraform-google-modules/project-factory/google"
version = "~> 15.0"
version = "~> 17.0"

name = local.cicd_project_name
random_project_id = true
Expand All @@ -40,6 +40,8 @@ module "cicd_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 0-bootstrap/modules/jenkins-agent/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ variable "default_region" {
default = "us-central1"
}

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

/* ----------------------------------------
Specific to CICD Project
---------------------------------------- */
Expand Down
4 changes: 3 additions & 1 deletion 0-bootstrap/terraform_cloud.tf.example
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ resource "tfe_run_trigger" "projects_bu2_shared_production" {

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

name = "${var.project_prefix}-b-cicd-wif-tfc"
random_project_id = true
Expand All @@ -251,6 +251,8 @@ module "tfc_cicd" {
"gkehub.googleapis.com",
"connectgateway.googleapis.com"
]

deletion_policy = var.project_deletion_policy
}

module "tfc-oidc" {
Expand Down
6 changes: 6 additions & 0 deletions 0-bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ variable "bucket_tfstate_kms_force_destroy" {
default = false
}

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

/* ----------------------------------------
Specific to Groups creation
---------------------------------------- */
Expand Down
29 changes: 20 additions & 9 deletions 1-org/envs/shared/projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ locals {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -43,6 +43,7 @@ module "org_audit_logs" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.common.id
deletion_policy = var.project_deletion_policy
activate_apis = ["logging.googleapis.com", "bigquery.googleapis.com", "billingbudgets.googleapis.com"]

labels = {
Expand All @@ -67,7 +68,7 @@ module "org_audit_logs" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -76,6 +77,7 @@ module "org_billing_export" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.common.id
deletion_policy = var.project_deletion_policy
activate_apis = ["logging.googleapis.com", "bigquery.googleapis.com", "billingbudgets.googleapis.com"]

labels = {
Expand All @@ -100,7 +102,7 @@ module "org_billing_export" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -109,6 +111,7 @@ module "common_kms" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.common.id
deletion_policy = var.project_deletion_policy
activate_apis = ["logging.googleapis.com", "cloudkms.googleapis.com", "billingbudgets.googleapis.com"]

labels = {
Expand All @@ -134,7 +137,7 @@ module "common_kms" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -143,6 +146,7 @@ module "org_secrets" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.common.id
deletion_policy = var.project_deletion_policy
activate_apis = ["logging.googleapis.com", "secretmanager.googleapis.com", "billingbudgets.googleapis.com"]

labels = {
Expand All @@ -167,7 +171,7 @@ module "org_secrets" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -176,6 +180,7 @@ module "interconnect" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
deletion_policy = var.project_deletion_policy
activate_apis = ["billingbudgets.googleapis.com", "compute.googleapis.com"]

labels = {
Expand All @@ -200,7 +205,7 @@ module "interconnect" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -209,6 +214,7 @@ module "scc_notifications" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.common.id
deletion_policy = var.project_deletion_policy
activate_apis = ["logging.googleapis.com", "pubsub.googleapis.com", "securitycenter.googleapis.com", "billingbudgets.googleapis.com", "cloudkms.googleapis.com"]

labels = {
Expand All @@ -233,7 +239,7 @@ module "scc_notifications" {

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

random_project_id = true
random_project_id_length = 4
Expand All @@ -242,6 +248,7 @@ module "dns_hub" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
deletion_policy = var.project_deletion_policy

activate_apis = [
"compute.googleapis.com",
Expand Down Expand Up @@ -274,7 +281,7 @@ module "dns_hub" {

module "base_network_hub" {
source = "terraform-google-modules/project-factory/google"
version = "~> 15.0"
version = "~> 17.0"
count = var.enable_hub_and_spoke ? 1 : 0

random_project_id = true
Expand All @@ -284,6 +291,7 @@ module "base_network_hub" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
deletion_policy = var.project_deletion_policy

activate_apis = [
"compute.googleapis.com",
Expand Down Expand Up @@ -324,7 +332,7 @@ resource "google_project_iam_member" "network_sa_base" {

module "restricted_network_hub" {
source = "terraform-google-modules/project-factory/google"
version = "~> 15.0"
version = "~> 17.0"
count = var.enable_hub_and_spoke ? 1 : 0

random_project_id = true
Expand All @@ -334,6 +342,7 @@ module "restricted_network_hub" {
org_id = local.org_id
billing_account = local.billing_account
folder_id = google_folder.network.id
deletion_policy = var.project_deletion_policy

activate_apis = [
"compute.googleapis.com",
Expand Down Expand Up @@ -373,6 +382,8 @@ module "base_restricted_environment_network" {
project_prefix = local.project_prefix
folder_id = google_folder.network.id

project_deletion_policy = var.project_deletion_policy

env = each.key
env_code = each.value

Expand Down
6 changes: 6 additions & 0 deletions 1-org/envs/shared/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,9 @@ variable "tfc_org_name" {
type = string
default = ""
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
4 changes: 2 additions & 2 deletions 1-org/modules/network/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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

random_project_id = true
random_project_id_length = 4
Expand Down Expand Up @@ -56,7 +56,7 @@ module "base_shared_vpc_host_project" {

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

random_project_id = true
random_project_id_length = 4
Expand Down
6 changes: 6 additions & 0 deletions 1-org/modules/network/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ variable "env_code" {
description = "A short form of the environment to prepare within the Google Cloud organization (ex. d)."
}

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

variable "project_budget" {
description = <<EOT
Budget configuration for projects.
Expand Down
1 change: 1 addition & 0 deletions 4-projects/business_unit_1/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ module "env" {
peering_iap_fw_rules_enabled = true
subnet_region = coalesce(var.instance_region, local.default_region)
subnet_ip_range = "10.3.64.0/21"
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions 4-projects/business_unit_1/development/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ variable "instance_region" {
type = string
default = null
}

variable "project_deletion_policy" {
description = "The deletion policy for the project created."
type = string
default = "PREVENT"
}
1 change: 1 addition & 0 deletions 4-projects/business_unit_1/nonproduction/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ module "env" {
peering_iap_fw_rules_enabled = true
subnet_region = coalesce(var.instance_region, local.default_region)
subnet_ip_range = "10.3.128.0/21"
project_deletion_policy = var.project_deletion_policy
}
6 changes: 6 additions & 0 deletions 4-projects/business_unit_1/nonproduction/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ variable "instance_region" {
type = string
default = null
}

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

0 comments on commit ebaf7dd

Please sign in to comment.