Skip to content

Commit 49347f5

Browse files
fix: update bucket naming to comply with guide definition (#904)
Co-authored-by: Bharath KKB <[email protected]>
1 parent f8920d9 commit 49347f5

File tree

16 files changed

+98
-18
lines changed

16 files changed

+98
-18
lines changed

0-bootstrap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ Each step has instructions for this change.
308308
| csr\_repos | List of Cloud Source Repos created by the module, linked to Cloud Build triggers. |
309309
| environment\_step\_terraform\_service\_account\_email | Environment Step Terraform Account |
310310
| gcs\_bucket\_cloudbuild\_artifacts | Bucket used to store Cloud/Build artifacts in CloudBuild project. |
311+
| gcs\_bucket\_cloudbuild\_logs | Bucket used to store Cloud/Build logs in CloudBuild project. |
311312
| gcs\_bucket\_tfstate | Bucket used for storing terraform state for Foundations Pipelines in Seed Project. |
312313
| group\_billing\_admins | Google Group for GCP Billing Administrators. |
313314
| group\_org\_admins | Google Group for GCP Organization Administrators. |

0-bootstrap/cb.tf

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ module "gcp_projects_state_bucket" {
6969
source = "terraform-google-modules/cloud-storage/google//modules/simple_bucket"
7070
version = "~> 3.2"
7171

72-
name = "bkt-b-gcp-projects-tfstate-${module.seed_bootstrap.seed_project_id}"
72+
name = "${var.bucket_prefix}-${module.seed_bootstrap.seed_project_id}-gcp-projects-tfstate"
7373
project_id = module.seed_bootstrap.seed_project_id
7474
location = var.default_region
7575
force_destroy = var.bucket_force_destroy
7676
}
7777

7878
module "tf_source" {
7979
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_source"
80-
version = "~> 6.3"
80+
version = "~> 6.4"
8181

8282
org_id = var.org_id
8383
folder_id = google_folder.bootstrap.id
@@ -144,7 +144,7 @@ module "tf_private_pool" {
144144

145145
module "tf_cloud_builder" {
146146
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_builder"
147-
version = "~> 6.3"
147+
version = "~> 6.4"
148148

149149
project_id = module.tf_source.cloudbuild_project_id
150150
dockerfile_repo_uri = module.tf_source.csr_repos[local.cloudbuilder_repo].url
@@ -155,6 +155,7 @@ module "tf_cloud_builder" {
155155
trigger_location = var.default_region
156156
enable_worker_pool = true
157157
worker_pool_id = module.tf_private_pool.private_worker_pool_id
158+
bucket_name = "${var.bucket_prefix}-${module.tf_source.cloudbuild_project_id}-tf-cloudbuilder-build-logs"
158159
}
159160

160161
module "bootstrap_csr_repo" {
@@ -193,7 +194,7 @@ module "build_terraform_image" {
193194

194195
module "tf_workspace" {
195196
source = "terraform-google-modules/bootstrap/google//modules/tf_cloudbuild_workspace"
196-
version = "~> 6.3"
197+
version = "~> 6.4"
197198
for_each = local.granular_sa
198199

199200
project_id = module.tf_source.cloudbuild_project_id
@@ -202,6 +203,8 @@ module "tf_workspace" {
202203
enable_worker_pool = true
203204
worker_pool_id = module.tf_private_pool.private_worker_pool_id
204205
state_bucket_self_link = local.cb_config[each.key].state_bucket
206+
log_bucket_name = "${var.bucket_prefix}-${module.tf_source.cloudbuild_project_id}-${local.cb_config[each.key].source}-build-logs"
207+
artifacts_bucket_name = "${var.bucket_prefix}-${module.tf_source.cloudbuild_project_id}-${local.cb_config[each.key].source}-build-artifacts"
205208
cloudbuild_plan_filename = "cloudbuild-tf-plan.yaml"
206209
cloudbuild_apply_filename = "cloudbuild-tf-apply.yaml"
207210
tf_repo_uri = module.tf_source.csr_repos[local.cb_config[each.key].source].url

0-bootstrap/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module "seed_bootstrap" {
5050
org_id = var.org_id
5151
folder_id = google_folder.bootstrap.id
5252
project_id = "${var.project_prefix}-b-seed"
53-
state_bucket_name = "${var.bucket_prefix}-b-tfstate"
53+
state_bucket_name = "${var.bucket_prefix}-${var.project_prefix}-b-seed-tfstate"
5454
force_destroy = var.bucket_force_destroy
5555
billing_account = var.billing_account
5656
group_org_admins = local.group_org_admins

0-bootstrap/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ output "gcs_bucket_cloudbuild_artifacts" {
9797
value = { for key, value in module.tf_workspace : key => replace(value.artifacts_bucket, local.bucket_self_link_prefix, "") }
9898
}
9999

100+
output "gcs_bucket_cloudbuild_logs" {
101+
description = "Bucket used to store Cloud/Build logs in CloudBuild project."
102+
value = { for key, value in module.tf_workspace : key => replace(value.logs_bucket, local.bucket_self_link_prefix, "") }
103+
}
104+
100105
output "projects_gcs_bucket_tfstate" {
101106
description = "Bucket used for storing terraform state for stage 4-projects foundations pipelines in seed project."
102107
value = module.gcp_projects_state_bucket.bucket.name

4-projects/business_unit_1/shared/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| cloudbuild\_project\_id | n/a |
1717
| default\_region | Default region to create resources where applicable. |
1818
| enable\_cloudbuild\_deploy | Enable infra deployment using Cloud Build. |
19+
| log\_buckets | GCS Buckets to store Cloud Build logs |
1920
| plan\_triggers\_id | CB plan triggers |
2021
| repos | CSRs to store source code |
2122
| state\_buckets | GCS Buckets to store TF state |

4-projects/business_unit_1/shared/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ output "state_buckets" {
4343
value = try(module.infra_pipelines[0].state_buckets, {})
4444
}
4545

46+
output "log_buckets" {
47+
description = "GCS Buckets to store Cloud Build logs"
48+
value = try(module.infra_pipelines[0].log_buckets, {})
49+
}
50+
4651
output "plan_triggers_id" {
4752
description = "CB plan triggers"
4853
value = try(module.infra_pipelines[0].plan_triggers_id, [])

4-projects/business_unit_2/shared/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
| cloudbuild\_project\_id | n/a |
1717
| default\_region | Default region to create resources where applicable. |
1818
| enable\_cloudbuild\_deploy | Enable infra deployment using Cloud Build. |
19+
| log\_buckets | GCS Buckets to store Cloud Build logs |
1920
| plan\_triggers\_id | CB plan triggers |
2021
| repos | CSRs to store source code |
2122
| state\_buckets | GCS Buckets to store TF state |

4-projects/business_unit_2/shared/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ output "state_buckets" {
4343
value = try(module.infra_pipelines[0].state_buckets, {})
4444
}
4545

46+
output "log_buckets" {
47+
description = "GCS Buckets to store Cloud Build logs"
48+
value = try(module.infra_pipelines[0].log_buckets, {})
49+
}
50+
4651
output "plan_triggers_id" {
4752
description = "CB plan triggers"
4853
value = try(module.infra_pipelines[0].plan_triggers_id, [])

4-projects/modules/base_env/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
| business\_unit | The business (ex. business\_unit\_1). | `string` | n/a | yes |
88
| env | The environment to prepare (ex. development). | `string` | n/a | yes |
99
| firewall\_enable\_logging | Toggle firewall logging for VPC Firewalls. | `bool` | `true` | no |
10-
| gcs\_bucket\_prefix | Name prefix to be used for GCS Bucket | `string` | `"cmek-encrypted-bucket"` | no |
10+
| gcs\_bucket\_prefix | Name prefix to be used for GCS Bucket | `string` | `"bkt"` | no |
1111
| key\_name | Name to be used for KMS Key | `string` | `"crypto-key-example"` | no |
1212
| key\_rotation\_period | Rotation period in seconds to be used for KMS Key | `string` | `"7776000s"` | no |
1313
| keyring\_name | Name to be used for KMS Keyring | `string` | `"sample-keyring"` | no |

4-projects/modules/base_env/example_storage_cmek.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module "gcs_buckets" {
6969
version = "~> 3.0"
7070
project_id = module.base_shared_vpc_project.project_id
7171
location = var.location_gcs
72-
name = "${var.gcs_bucket_prefix}-${lower(var.location_gcs)}-${random_string.bucket_name.result}"
72+
name = "${var.gcs_bucket_prefix}-${module.base_shared_vpc_project.project_id}-${lower(var.location_gcs)}-cmek-encrypted-${random_string.bucket_name.result}"
7373
bucket_policy_only = true
7474
encryption = {
7575
default_kms_key_name = module.kms.keys[var.key_name]

0 commit comments

Comments
 (0)