Skip to content

Commit 3c34fda

Browse files
committed
Merge branch 'main' into feat/add_outputs_for_dr
2 parents 31867fe + c99808d commit 3c34fda

File tree

4 files changed

+33
-23
lines changed

4 files changed

+33
-23
lines changed

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres
77
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
# [0.12.0] - 2026-01-22
10+
11+
[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-application-bucket-creation-helper/compare/0.11.0...0.12.0)
12+
13+
### Added
14+
15+
- Added output`disaster_recovery_bucket_names` to provide a map from input bucket names to disaster recovery bucket names.
16+
17+
### Fixed
18+
19+
- Fixed `bucket_obj_adm` and `bucket_obj_vwr` variables causing "Invalid for_each argument" error when used with `append_random_suffix = true`. The `for_each` key for IAM member resources now uses the static input bucket name instead of the dynamically generated name (with random suffix).
20+
21+
### Changed
22+
23+
- **BREAKING CHANGE for existing users of `bucket_obj_adm`/`bucket_obj_vwr`**: The `for_each` key for `google_storage_bucket_iam_member.default_storage_admin` and `google_storage_bucket_iam_member.default_storage_viewer` resources has changed from `<generated_bucket_name>--<member>` to `<input_bucket_name>--<member>`.
24+
25+
**Example**: If your bucket input name is `myapp` and it gets a random suffix `a1b2`, the key changes from `myapp-a1b2--group:admins@example.com` to `myapp--group:admins@example.com`.
26+
27+
**Impact**: Terraform will plan to destroy and recreate the IAM bindings. This is safe - the IAM permissions will be briefly removed and immediately recreated. No data loss occurs.
28+
29+
**Migration**: No action required. Run `terraform apply` to recreate the IAM bindings with the new keys. If you want to avoid the brief permission gap, you can use `terraform state mv` to rename the resources before applying.
30+
931
# [0.11.0] - 2025-12-10
1032

1133
[Compare with previous version](https://github.com/sparkfabrik/terraform-google-gcp-application-bucket-creation-helper/compare/0.10.0...0.11.0)

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ want to import existing buckets with a known name.
9999
| <a name="output_buckets_access_credentials"></a> [buckets\_access\_credentials](#output\_buckets\_access\_credentials) | Access credentials for the application buckets |
100100
| <a name="output_details_of_used_tag_keys"></a> [details\_of\_used\_tag\_keys](#output\_details\_of\_used\_tag\_keys) | Details of all the tag keys passed to this module (globals and per bucket). |
101101
| <a name="output_details_of_used_tag_values"></a> [details\_of\_used\_tag\_values](#output\_details\_of\_used\_tag\_values) | Details of all the tag values passed to this module (globals and per bucket). |
102-
| <a name="output_disaster_recovery_bucket_names"></a> [disaster\_recovery\_bucket\_names](#output\_disaster\_recovery\_bucket\_names) | The list with the names of the disaster recovery buckets. |
103-
| <a name="output_disaster_recovery_bucket_names_map"></a> [disaster\_recovery\_bucket\_names\_map](#output\_disaster\_recovery\_bucket\_names\_map) | Map from input bucket name to disaster recovery bucket name. |
102+
| <a name="output_disaster_recovery_bucket_names"></a> [disaster\_recovery\_bucket\_names](#output\_disaster\_recovery\_bucket\_names) | Map from input bucket name to disaster recovery bucket name. Use values() to get a list. |
104103
| <a name="output_generated_bucket_names"></a> [generated\_bucket\_names](#output\_generated\_bucket\_names) | The list with the names of the buckets managed by this module. |
105-
| <a name="output_generated_bucket_names_map"></a> [generated\_bucket\_names\_map](#output\_generated\_bucket\_names\_map) | Map from input bucket name to generated bucket name (with random suffix if enabled). |
106104
## Resources
107105

108106
| Name | Type |

main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ locals {
99
bucket.append_random_suffix ? "${bucket.name}-${random_id.resources_suffix[bucket.name].hex}" : bucket.name
1010
}
1111

12-
generated_bucket_obj_admin_list = distinct(flatten([
12+
generated_bucket_obj_admin_list = flatten([
1313
for bucket in var.buckets_list : [
1414
for bucket_obj_adm in bucket.bucket_obj_adm : {
15-
bucket_name = local.generated_bucket_names[bucket.name]
16-
bucket_obj_adm = bucket_obj_adm
15+
bucket_name = bucket.name
16+
bucket_obj_admin = bucket_obj_adm
1717
}
1818
]
19-
]))
19+
])
2020

21-
generated_bucket_obj_vwr_list = distinct(flatten([
21+
generated_bucket_obj_vwr_list = flatten([
2222
for bucket in var.buckets_list : [
2323
for bucket_obj_vwr in bucket.bucket_obj_vwr : {
24-
bucket_name = local.generated_bucket_names[bucket.name]
24+
bucket_name = bucket.name
2525
bucket_obj_vwr = bucket_obj_vwr
2626
}
2727
]
28-
]))
28+
])
2929

3030
}
3131

@@ -194,15 +194,15 @@ resource "google_storage_bucket_iam_member" "viewer" {
194194
# Default Storage Admin Role
195195
resource "google_storage_bucket_iam_member" "default_storage_admin" {
196196
for_each = { for bucket in local.generated_bucket_obj_admin_list : "${bucket.bucket_name}--${bucket.bucket_obj_admin}" => bucket }
197-
bucket = google_storage_bucket.application[each.value.name].name
197+
bucket = google_storage_bucket.application[each.value.bucket_name].name
198198
role = "roles/storage.objectAdmin"
199199
member = each.value.bucket_obj_admin
200200
}
201201

202202
# Default Storage Viewer Role
203203
resource "google_storage_bucket_iam_member" "default_storage_viewer" {
204204
for_each = { for bucket in local.generated_bucket_obj_vwr_list : "${bucket.bucket_name}--${bucket.bucket_obj_vwr}" => bucket }
205-
bucket = google_storage_bucket.application[each.value.name].name
205+
bucket = google_storage_bucket.application[each.value.bucket_name].name
206206
role = "roles/storage.objectViewer"
207207
member = each.value.bucket_obj_vwr
208208
}

outputs.tf

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@ output "generated_bucket_names" {
2626
value = [for k, v in local.generated_bucket_names : v]
2727
}
2828

29-
output "generated_bucket_names_map" {
30-
description = "Map from input bucket name to generated bucket name (with random suffix if enabled)."
31-
value = local.generated_bucket_names
32-
}
33-
3429
output "disaster_recovery_bucket_names" {
35-
description = "The list with the names of the disaster recovery buckets."
36-
value = [for k, bucket in google_storage_bucket.disaster_recovery : bucket.name]
37-
}
38-
39-
output "disaster_recovery_bucket_names_map" {
40-
description = "Map from input bucket name to disaster recovery bucket name."
30+
description = "Map from input bucket name to disaster recovery bucket name. Use values() to get a list."
4131
value = { for k, bucket in google_storage_bucket.disaster_recovery : k => bucket.name }
4232
}

0 commit comments

Comments
 (0)