Skip to content

feat(RHOAIENG-47026): add gcs resource#5

Open
syntaxsdev wants to merge 1 commit intomainfrom
feat/add-gcs-bucket-
Open

feat(RHOAIENG-47026): add gcs resource#5
syntaxsdev wants to merge 1 commit intomainfrom
feat/add-gcs-bucket-

Conversation

@syntaxsdev
Copy link
Copy Markdown
Contributor

@syntaxsdev syntaxsdev commented Apr 7, 2026

This adds a simple GCS resource to the IaS configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

Walkthrough

This PR adds Terraform infrastructure code to enable the Google Cloud Storage API and provision a public GCS bucket named ambient-code-pull-reviews with lifecycle management, public read access, and write permissions for GitHub Actions via workload identity.

Changes

Cohort / File(s) Summary
GCS API Enablement
gcp/apis.tf
Added google_project_service resource to enable the storage.googleapis.com API.
GCS Bucket Configuration
gcp/pull-reviews.tf
Created new GCS bucket with 45-day object lifecycle rule. Configured public read access via allUsers role and write access for GitHub Actions workload identity principal targeting the ambient-code/pull-reviews repository.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description 'This adds a simple GCS resource to the IaS configuration' is directly related to the changeset, which adds GCS bucket resources and supporting configurations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately describes the main change: adding Google Cloud Storage (GCS) resources including a new bucket and IAM configurations across two Terraform files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/add-gcs-bucket-

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@gcp/pull-reviews.tf`:
- Around line 7-22: Add an explicit dependency so the google_storage_bucket
"pull_reviews" waits for the storage API to be enabled; update the
google_storage_bucket resource (resource "google_storage_bucket" "pull_reviews")
to include a depends_on referencing the google_project_service resource that
enables the storage API (e.g., depends_on = [google_project_service.storage]) to
prevent the bucket creation from running before the API is available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0980db37-beef-4ece-97b9-1f6deb5dd911

📥 Commits

Reviewing files that changed from the base of the PR and between 19cfc49 and 58b46f3.

📒 Files selected for processing (2)
  • gcp/apis.tf
  • gcp/pull-reviews.tf

Comment on lines +7 to +22
resource "google_storage_bucket" "pull_reviews" {
project = var.project_id
name = "ambient-code-pull-reviews"
location = "US"

uniform_bucket_level_access = true

lifecycle_rule {
action {
type = "Delete"
}
condition {
age = 45
}
}
}
Copy link
Copy Markdown

@coderabbitai coderabbitai bot Apr 7, 2026

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider adding explicit dependency on the storage API.

Without depends_on, Terraform may attempt to create this bucket before google_project_service.storage is fully enabled, causing failures on initial apply.

Proposed fix
 resource "google_storage_bucket" "pull_reviews" {
   project  = var.project_id
   name     = "ambient-code-pull-reviews"
   location = "US"

   uniform_bucket_level_access = true

   lifecycle_rule {
     action {
       type = "Delete"
     }
     condition {
       age = 45
     }
   }
+
+  depends_on = [google_project_service.storage]
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resource "google_storage_bucket" "pull_reviews" {
project = var.project_id
name = "ambient-code-pull-reviews"
location = "US"
uniform_bucket_level_access = true
lifecycle_rule {
action {
type = "Delete"
}
condition {
age = 45
}
}
}
resource "google_storage_bucket" "pull_reviews" {
project = var.project_id
name = "ambient-code-pull-reviews"
location = "US"
uniform_bucket_level_access = true
lifecycle_rule {
action {
type = "Delete"
}
condition {
age = 45
}
}
depends_on = [google_project_service.storage]
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@gcp/pull-reviews.tf` around lines 7 - 22, Add an explicit dependency so the
google_storage_bucket "pull_reviews" waits for the storage API to be enabled;
update the google_storage_bucket resource (resource "google_storage_bucket"
"pull_reviews") to include a depends_on referencing the google_project_service
resource that enables the storage API (e.g., depends_on =
[google_project_service.storage]) to prevent the bucket creation from running
before the API is available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@coderabbitai why would it do that? We don't want to add explicit deps on everything in gcp/apis.tf - that's noisy

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@ktdreyer, fair point — you're right to push back. The concern was about a potential race condition on an initial terraform apply when the Storage API hasn't been enabled yet, but in practice:

  1. Google's own best-practice guidance favors implicit dependencies (e.g., project_id = module.project_services.project_id) over explicit depends_on, since referencing output attributes ensures Terraform waits for the upstream resource automatically.
  2. The Storage API is a foundational GCP service and is very likely already enabled on any non-brand-new project, making this a low-real-world-risk concern.
  3. Scattering depends_on = [google_project_service.*] across every resource in the codebase is noisy and adds maintenance overhead, as you noted.

The comment was already marked as a nitpick/trivial and was overly cautious. I'll drop it — no change needed here.


📝 Learnings were identified and not saved (knowledge base disabled). Enable

@ktdreyer ktdreyer self-requested a review April 7, 2026 17:11
resource "google_storage_bucket_iam_member" "pull_reviews_gha_write" {
bucket = google_storage_bucket.pull_reviews.name
role = "roles/storage.objectCreator"
member = "principalSet://iam.googleapis.com/${google_iam_workload_identity_pool.github_pool.name}/attribute.repository/ambient-code/pull-reviews"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if we need principalSet to point at ambient-code/platform instead, if the actions will run under that repo?

I'm not sure how WIF authz works when we're including one action in another repo.

service = "storage.googleapis.com"
disable_on_destroy = false
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This part LGTM

@ktdreyer ktdreyer changed the title feat: add gcs resource feat(RHOAIENG-47026): add gcs resource Apr 7, 2026
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.

2 participants