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

fix: add google_storage_bucket in bootstrap module #241

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

k9ert
Copy link
Contributor

@k9ert k9ert commented Jan 6, 2025

Without this, i get:

│ Error: googleapi: Error 412: Request violates constraint 'constraints/storage.uniformBucketLevelAccess', conditionNotMet
│ 
│   with module.bootstrap.google_storage_bucket.tf_state,
│   on .terraform/modules/bootstrap/modules/bootstrap/gcp/tf-state-bucket.tf line 1, in resource "google_storage_bucket" "tf_state":
│    1: resource "google_storage_bucket" "tf_state" {
│ 

This seems to be related to the way new organisations are setup by default in GCP as this contraint is coming from the org.

https://cloud.google.com/storage/docs/uniform-bucket-level-access

@k9ert k9ert changed the title fixing google_storage_bucket in bootstrap module fix: add google_storage_bucket in bootstrap module Jan 8, 2025
@openoms openoms requested a review from krtk6160 January 8, 2025 12:04
@@ -5,7 +5,8 @@ resource "google_storage_bucket" "tf_state" {
versioning {
enabled = true
}
force_destroy = local.tf_state_bucket_force_destroy
force_destroy = local.tf_state_bucket_force_destroy
uniform_bucket_level_access = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be required in bootstrap stage. The inception stage takes ownership for all config for this bucket (including setting uniform_bucket_level_access = true) - bootstrap simply creates it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here is the default list of constraints for new orgs:

gcloud resource-manager org-policies list --organization=247915926625
CONSTRAINT                                                      LIST_POLICY  BOOLEAN_POLICY  ETAG
constraints/compute.setNewProjectDefaultToZonalDNSOnly          -            SET             CJjT2LgGEJi-5ZkB
constraints/essentialcontacts.allowedContactDomains             SET          -               CJjT2LgGEMCIrJ4B
constraints/iam.allowedPolicyMemberDomains                      SET          -               CKbB5LgGEPi9tJgB
constraints/iam.disableServiceAccountKeyUpload                  -            SET             CJjT2LgGEJj32JcB
constraints/iam.automaticIamGrantsForDefaultServiceAccounts     -            SET             CJjT2LgGEJjgrZoB
constraints/resourcemanager.allowedExportDestinations           SET          -               CMGL7rgGEODJn-QB
constraints/resourcemanager.allowedImportSources                SET          -               CKGA7rgGEMCV4s0C
constraints/storage.uniformBucketLevelAccess                    -            SET             CJjT2LgGEKCh2JcB
constraints/compute.restrictProtocolForwardingCreationForTypes  SET          -               CJjT2LgGELCK0JcB

With that, you get the issue above! So, why not creating the bucket in a compliant way just right from the start? The alternative would be to disable explicitely that constraint on a project level (which is definitely possible) but why should we do that as this is suppose to improve the security on the buckets?

@krtk6160 krtk6160 merged commit bbe12fe into GaloyMoney:main Jan 30, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants