github-ci-bootstrap: create a bucket for Terraform binary plan files - #36
Merged
Conversation
The generate-terraform-plan GitHub action (Khan/actions#274) uploads binary plans to GCS instead of committing them, because a binary plan embeds a full copy of the Terraform state including sensitive values. Every consumer of the plan/apply actions needs the same bucket with the same security posture, so create it here alongside the CI service accounts it belongs to: per-service naming, uniform bucket-level access, public access prevention, a lifecycle rule for plans that are never applied, and object access for the rw service account only. Opt out with create_terraform_plans_bucket = false for setups that do not use the plan/apply actions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Khan/actions#274 changes
generate-terraform-plan/apply-terraform-planto store the Terraform binary plan in GCS instead of committing it to git (a binary plan embeds a full copy of the Terraform state, including sensitive values in cleartext). Every consumer of those actions needs the same bucket with the same security posture, so this PR has the bootstrap module create it, next to the CI service accounts and WIF providers it belongs with, instead of each repo hand-rolling it.What the module now creates (opt-out via
create_terraform_plans_bucket = false)terraform-plans-{org}-{repo}-{service}(same normalization as the state bucket; overridable viaterraform_plans_bucket) inkhan-internal-services, with uniform bucket-level access and public access prevention enforced.roles/storage.objectAdminon the bucket for the read/write service account only (it uploads on plan, downloads and deletes on apply). The read-only account used for PR-branch plans gets no grant.terraform_plans_expiration_days(default 30); applied plans are already deleted by the apply action, this catches superseded plan PRs.terraform_plans_bucketto feed the actions'plan_bucketinput.Rollout
Additive and enabled by default: consumers get the bucket on their next module bump plus a local bootstrap
terraform apply. For culture-cron, which already createdkhan-culture-cron-terraform-plansby hand in its bootstrap (Khan/culture-cron#28) during testing, adoption means passingterraform_plans_bucket = "khan-culture-cron-terraform-plans"and moving the two resources into the module in its bootstrap state:Related: #35 (make
write_branch_patternsexplicit); if both land together, tag a singlegithub-ci-bootstrap-v2.0.0.