Skip to content

Conversation

@omendra-tomar
Copy link
Contributor

@omendra-tomar omendra-tomar commented Aug 29, 2025

Description

Related issues

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have created feat/bugfix branch out of develop branch
  • Code passes linting/formatting checks
  • Changes to resources have been tested in our dev environments
  • I have made corresponding changes to the documentation

Testing

Reviewer instructions

Summary by CodeRabbit

  • New Features

    • Google Cloud Pub/Sub module v1.0: environment-aware naming, labeling, and per-environment project targeting.
    • Create topics with configurable message retention, optional schema validation, and optional KMS encryption.
    • Add pull and push subscriptions with configurable ack deadlines, push endpoints, and generated per-environment names.
    • Outputs expose topic and subscription identifiers.
  • Documentation

    • Added README covering capabilities, environment behavior, examples, and security considerations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

Adds a new Google Cloud Pub/Sub Terraform module (default flavor v1.0): README, facets.yaml, variables, shared locals, topic resource, optional schema, simplified pull and push subscriptions, and outputs; resources use environment data for naming, labels, and provider/project resolution.

Changes

Cohort / File(s) Change Summary
Documentation
modules/pubsub/default/1.0/README.md
Added README describing module behavior, environment-aware naming/labels, resources created, and security considerations.
Facet definition
modules/pubsub/default/1.0/facets.yaml
Added facets.yaml declaring a pubsub facet (flavor: test, version: 1.0), validated_files, spec for topic/push/pull/schema, inputs/outputs, and a sample instance.
Core locals
modules/pubsub/default/1.0/main.tf
Added shared locals: project_id (from inputs.cloud_account.project or provider), spec binding, env-suffixed topic_name, merged filtered_labels, and schema_enabled flag.
Variables
modules/pubsub/default/1.0/variables.tf
Added instance, instance_name, environment, and inputs variables; instance.spec shape includes topic, retention, pull_subscriptions, push_subscriptions; validations enforce ack_deadline_seconds between 10–600.
Topic resource
modules/pubsub/default/1.0/topic.tf
Added google_pubsub_topic.this with env-suffixed name, labels, and message_retention_duration; uses provider/project default; notes basic-version limitations.
Schema (optional)
modules/pubsub/default/1.0/schema.tf
Added conditional google_pubsub_schema.this created only when schema is enabled and name/definition provided.
Pull subscriptions
modules/pubsub/default/1.0/pull_subscriptions.tf
Added simplified google_pubsub_subscription.pull (for_each) with env-suffixed names, labels, ack_deadline_seconds; advanced features intentionally omitted.
Push subscriptions
modules/pubsub/default/1.0/push_subscriptions.tf
Added simplified google_pubsub_subscription.push (for_each) with env-suffixed names, labels, ack_deadline_seconds and push_config.push_endpoint; OIDC/auth and advanced features omitted.
Outputs
modules/pubsub/default/1.0/outputs.tf
Added locals aggregating output_attributes (topic id/name, labels, topic_full_name, pull/push subscription names) and output_interfaces as an empty map.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Facet as facets.yaml
  participant TF as Pub/Sub Module
  participant GCP as GCP API

  Dev->>Facet: Provide instance spec (topic, subs, retention)
  Facet->>TF: Validate & forward inputs
  TF->>TF: Compute env-suffixed names, labels, locals
  TF->>GCP: Create Topic
  alt schema enabled and defined
    TF->>GCP: Create Schema
  end
  par create subscriptions
    TF->>GCP: Create Pull Subscriptions (for_each)
    TF->>GCP: Create Push Subscriptions (for_each with push_endpoint)
  end
  TF-->>Dev: Return outputs (topic id/name, sub names, labels)
  note right of TF: Project resolved from inputs.cloud_account.project or provider default
Loading

Suggested reviewers

  • rr0hit
  • anshulsao
  • vishnukv-facets
  • ishaankalra
  • pramodh-ayyappan

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description is merely the unfilled template without any summary of changes, context, related issues, or testing details, so it fails to inform reviewers of the intent, scope, or verification of this module. Please complete the template by providing a concise summary of the changes and motivation, link any related issues or tasks, select the type of change, mark the checklist items, and include testing results and reviewer instructions.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly identifies the addition of a Pub/Sub module which is the primary change in this pull request and avoids extraneous details, making it clear to reviewers what the PR introduces.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Pub/Sub

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
Contributor

@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: 17

🧹 Nitpick comments (9)
modules/pubsub/default/1.0/README.md (1)

24-29: Fix resource list phrasing (minor terminology/grammar).

  • “Protocol Buffer” → “Protocol Buffers”
  • “Client-pull based” → “Client pull‑based”
  • Consider “Dead‑letter topics” (GCP docs commonly say “dead letter”/“dead-letter”).

Apply:

- - **Pub/Sub Schema** - Optional message validation schema supporting AVRO and Protocol Buffer formats
- - **Pull Subscriptions** - Client-pull based subscriptions with configurable acknowledgment settings
+ - **Pub/Sub Schema** - Optional message validation schema supporting AVRO and Protocol Buffers
+ - **Pull Subscriptions** - Client pull‑based subscriptions with configurable acknowledgment settings
- - **Dead Letter Topics** - Automatic handling of failed message delivery (when configured)
+ - **Dead‑letter topics** - Automatic handling of failed message delivery (when configured)
modules/pubsub/default/1.0/variables.tf (1)

1-24: Confirm Terraform/core provider versions support optional() and alltrue().

These require modern Terraform (>= 1.3). Add a terraform block with required_version and required_providers in this module to make the constraint explicit.

I can add a versions.tf with pinned constraints if you confirm your pipeline versions.

modules/pubsub/default/1.0/topic.tf (1)

16-18: Validate/normalize retention duration.

Ensure local.topic_message_retention_duration conforms to Pub/Sub's format and limits. Consider adding a variable validation regex like ^\d+s$ with acceptable min/max.

I can add a regex validation in variables.tf if desired.

modules/pubsub/default/1.0/outputs.tf (1)

6-7: Use fully-qualified topic name for “topic_full_name”.

google_pubsub_topic.this.id returns projects/{project}/topics/{name}; name is just the short name.

Apply:

-    topic_full_name         = google_pubsub_topic.this.name
+    topic_full_name         = google_pubsub_topic.this.id
modules/pubsub/default/1.0/schema.tf (1)

16-17: Remove or wire up schema_encoding
modules/pubsub/default/1.0/schema.tf line 16 defines schema_encoding, but it isn’t referenced anywhere in this module. Either hook it into topic.schema_settings in topic.tf or remove it to avoid drift.

modules/pubsub/default/1.0/push_subscriptions.tf (1)

21-40: Consider minimal resilience knobs (optional)

Optional but useful in most prod setups: retry_policy, dead_letter_policy, and filter. Even if “simplified,” exposing these as optional fields prevents later breaking changes.

modules/pubsub/default/1.0/facets.yaml (1)

50-71: Optional: Add OIDC config to push subscriptions

Prepares the facet for authenticated push.

Apply:

         ^[a-zA-Z0-9_-]+$:
           type: object
           title: Push Subscription Configuration
           properties:
             push_endpoint:
               type: string
               title: Push Endpoint
               description: The URL where messages will be pushed
+            oidc:
+              type: object
+              title: OIDC Token (optional)
+              properties:
+                service_account_email:
+                  type: string
+                  title: Service Account Email
+                audience:
+                  type: string
+                  title: Audience (optional)
             ack_deadline_seconds:
               type: integer
               title: Acknowledgment Deadline (seconds)
               description: Time before Pub/Sub attempts redelivery
               default: 20
               minimum: 10
               maximum: 600
modules/pubsub/default/1.0/pull_subscriptions.tf (2)

11-18: Minor: defensive defaults and validation

If ack_deadline_seconds is omitted, this renders null. Consider defaulting to 20 here to mirror the facet default.

Apply:

-      ack_deadline_seconds = config.ack_deadline_seconds
+      ack_deadline_seconds = try(config.ack_deadline_seconds, 20)

21-33: Optional resiliency knobs

Consider optional retry_policy and dead_letter_policy to prevent message loss/backlogs in prod.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38c6b1d and 38d4126.

📒 Files selected for processing (9)
  • modules/pubsub/default/1.0/README.md (1 hunks)
  • modules/pubsub/default/1.0/facets.yaml (1 hunks)
  • modules/pubsub/default/1.0/main.tf (1 hunks)
  • modules/pubsub/default/1.0/outputs.tf (1 hunks)
  • modules/pubsub/default/1.0/pull_subscriptions.tf (1 hunks)
  • modules/pubsub/default/1.0/push_subscriptions.tf (1 hunks)
  • modules/pubsub/default/1.0/schema.tf (1 hunks)
  • modules/pubsub/default/1.0/topic.tf (1 hunks)
  • modules/pubsub/default/1.0/variables.tf (1 hunks)
🧰 Additional context used
🪛 LanguageTool
modules/pubsub/default/1.0/README.md

[grammar] ~24-~24: There might be a mistake here.
Context: ...le retention and optional KMS encryption - Pub/Sub Schema - Optional message vali...

(QB_NEW_EN)


[grammar] ~25-~25: There might be a mistake here.
Context: ...porting AVRO and Protocol Buffer formats - Pull Subscriptions - Client-pull based...

(QB_NEW_EN)


[grammar] ~26-~26: There might be a mistake here.
Context: ...ith configurable acknowledgment settings - Push Subscriptions - HTTP endpoint pus...

(QB_NEW_EN)


[grammar] ~27-~27: There might be a mistake here.
Context: ...ions with retry and dead letter policies - Dead Letter Topics - Automatic handlin...

(QB_NEW_EN)

Comment on lines 60 to 71
properties:
push_endpoint:
type: string
title: Push Endpoint
description: The URL where messages will be pushed
ack_deadline_seconds:
type: number
title: Acknowledgment Deadline (seconds)
description: Time before Pub/Sub attempts redelivery
default: 20
minimum: 10
maximum: 600
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Make push_endpoint required for push subscriptions

Without this, the module can render invalid resources.

Apply:

       patternProperties:
         ^[a-zA-Z0-9_-]+$:
           type: object
           title: Push Subscription Configuration
           properties:
             push_endpoint:
               type: string
               title: Push Endpoint
               description: The URL where messages will be pushed
             ack_deadline_seconds:
-              type: number
+              type: integer
               title: Acknowledgment Deadline (seconds)
               description: Time before Pub/Sub attempts redelivery
               default: 20
               minimum: 10
               maximum: 600
+          required:
+            - push_endpoint
📝 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
properties:
push_endpoint:
type: string
title: Push Endpoint
description: The URL where messages will be pushed
ack_deadline_seconds:
type: number
title: Acknowledgment Deadline (seconds)
description: Time before Pub/Sub attempts redelivery
default: 20
minimum: 10
maximum: 600
patternProperties:
^[a-zA-Z0-9_-]+$:
type: object
title: Push Subscription Configuration
properties:
push_endpoint:
type: string
title: Push Endpoint
description: The URL where messages will be pushed
ack_deadline_seconds:
type: integer
title: Acknowledgment Deadline (seconds)
description: Time before Pub/Sub attempts redelivery
default: 20
minimum: 10
maximum: 600
required:
- push_endpoint
🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/facets.yaml around lines 60 to 71, the
push_endpoint property is currently optional which allows generation of invalid
push subscription resources; update the schema to make push_endpoint required by
adding it to the schema's required array (e.g., add a required entry that
includes "push_endpoint") so the validator/enforcer will demand a push_endpoint
value when creating push subscriptions.

Comment on lines 7 to 9
# Use environment's project automatically - no user input needed
project_id = null # Let Terraform use the default project from provider/environment
spec = var.instance.spec
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Set project_id from environment to bind all resources.

project_id = null is a no‑op. Pull an explicit value from var.environment and reuse across resources.

Apply:

-  project_id = null # Let Terraform use the default project from provider/environment
+  # Prefer explicit scoping; add `project_id` to var.environment and set it here
+  project_id = try(var.environment.project_id, null)

Also update variables.tf to include project_id in environment type.

📝 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
# Use environment's project automatically - no user input needed
project_id = null # Let Terraform use the default project from provider/environment
spec = var.instance.spec
# Use environment's project automatically - no user input needed
# Prefer explicit scoping; add `project_id` to var.environment and set it here
project_id = try(var.environment.project_id, null)
spec = var.instance.spec
🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/main.tf around lines 7-9, replace the no-op
project_id = null with an explicit reference to the environment project ID
(e.g., project_id = var.environment.project_id or a
local.environment_project_id) so the module binds resources to the correct
project, and update modules/pubsub/default/1.0/variables.tf to add project_id to
the environment object/type (and any callers/roots that supply var.environment)
so the value is required/propagated consistently across all resources.

Comment on lines +11 to +13
# Generate topic name from user input and cluster_code
topic_name = "${var.instance.spec.topic_name}-${var.environment.cluster_code}"

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Normalize topic name to safe charset and case.

Guard against unexpected chars in cluster_code and enforce lowercase to keep naming consistent.

Apply:

-  topic_name = "${var.instance.spec.topic_name}-${var.environment.cluster_code}"
+  topic_name = lower(regexreplace("${var.instance.spec.topic_name}-${var.environment.cluster_code}", "[^a-z0-9._-]", "-"))
📝 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
# Generate topic name from user input and cluster_code
topic_name = "${var.instance.spec.topic_name}-${var.environment.cluster_code}"
# Generate topic name from user input and cluster_code
topic_name = lower(regexreplace("${var.instance.spec.topic_name}-${var.environment.cluster_code}", "[^a-z0-9._-]", "-"))
🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/main.tf around lines 11 to 13, the topic_name
interpolation uses raw values which may contain unexpected characters and mixed
case; normalize both parts by replacing any characters outside [A-Za-z0-9-] with
a safe separator (e.g. "-") and convert the result to lowercase before
concatenation. Update the expression to run regexreplace on
var.instance.spec.topic_name and var.environment.cluster_code to sanitize them,
then wrap the final string with lower() so the produced topic_name is lowercase
and contains only allowed characters.

Comment on lines +6 to +17
locals {
# Schema-specific configuration
schema_config = local.schema_enabled && lookup(local.spec, "schema", null) != null ? local.spec.schema : null

# Schema name with environment suffix (only when schema is enabled and name is provided)
schema_name = local.schema_enabled && local.schema_config != null ? lookup(local.schema_config, "name", null) != null ? "${local.schema_config.name}-${var.environment.cluster_code}" : null : null

# Schema properties
schema_type = local.schema_enabled && local.schema_config != null ? lookup(local.schema_config, "type", null) : null
schema_definition = local.schema_enabled && local.schema_config != null ? lookup(local.schema_config, "definition", null) : null
schema_encoding = local.schema_enabled && local.schema_config != null ? lookup(local.schema_config, "encoding", null) : null
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Mismatch: spec has no schema block; this code expects local.spec.schema

locals.schema_config reads local.spec.schema, but facets.yaml defines no schema property, making schema creation unreachable.

I’ve proposed the facets.yaml additions in its file comment.

Comment on lines +11 to +22
# Create Pub/Sub topic - uses environment's default project
resource "google_pubsub_topic" "this" {
name = local.topic_name
labels = local.filtered_labels

# Topic configuration
message_retention_duration = local.topic_message_retention_duration

# No project specified - uses default from provider/environment
# No schema support in basic version
# No KMS encryption in basic version
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Explicitly set project to avoid accidental cross‑project applies.

Current resource relies on provider default project. If multiple providers are used, this is risky.

Apply:

 resource "google_pubsub_topic" "this" {
-  name   = local.topic_name
-  labels = local.filtered_labels
+  project = local.project_id
+  name    = local.topic_name
+  labels  = local.filtered_labels

Follow‑up: wire local.project_id (see main.tf comment) to an explicit environment project.

📝 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
# Create Pub/Sub topic - uses environment's default project
resource "google_pubsub_topic" "this" {
name = local.topic_name
labels = local.filtered_labels
# Topic configuration
message_retention_duration = local.topic_message_retention_duration
# No project specified - uses default from provider/environment
# No schema support in basic version
# No KMS encryption in basic version
}
resource "google_pubsub_topic" "this" {
project = local.project_id
name = local.topic_name
labels = local.filtered_labels
# Topic configuration
message_retention_duration = local.topic_message_retention_duration
# No schema support in basic version
# No KMS encryption in basic version
}
🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/topic.tf around lines 11 to 22, the
google_pubsub_topic resource omits the project attribute and relies on the
provider default which can cause accidental cross‑project applies; add a project
= local.project_id line to the resource block (wiring the local.project_id
referenced in main.tf) so the topic is created in the intended environment
project and not whatever provider default is active.

Comment on lines +9 to +11
topic_name = optional(string, "my-topic")
topic_message_retention_duration = optional(string, "604800s")

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for topic name format and length.

Pub/Sub names have character and length constraints. Validate early to avoid plan/apply failures.

Apply:

   spec = object({
     # Topic Configuration
-    topic_name                       = optional(string, "my-topic")
+    topic_name                       = optional(string, "my-topic")
     topic_message_retention_duration = optional(string, "604800s")

And append after Line 41:

+  # Topic name validations
+  validation {
+    condition     = can(regex("^[-a-zA-Z0-9._]{3,255}$", var.instance.spec.topic_name))
+    error_message = "topic_name must be 3–255 chars; allowed: letters, numbers, hyphen, underscore, period."
+  }
📝 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
topic_name = optional(string, "my-topic")
topic_message_retention_duration = optional(string, "604800s")
spec = object({
# Topic Configuration
topic_name = optional(string, "my-topic")
topic_message_retention_duration = optional(string, "604800s")
})
# Topic name validations
validation {
condition = can(regex("^[-a-zA-Z0-9._]{3,255}$", var.instance.spec.topic_name))
error_message = "topic_name must be 3–255 chars; allowed: letters, numbers, hyphen, underscore, period."
}
🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/variables.tf around lines 9-11 and append after
line 41, add validation for the topic_name variable so Terraform fails fast on
bad values: require topic_name length between 3 and 255 characters and enforce
allowed Pub/Sub characters via a regex (e.g. ^[A-Za-z0-9-_.~+%]+$); implement
this using a validation block on the variable (with a clear error message) so
both default and user-supplied values are checked before plan/apply.

Comment on lines +18 to +21
push_subscriptions = optional(map(object({
push_endpoint = string
ack_deadline_seconds = optional(number, 20)
})), {})
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enforce HTTPS push endpoints.

Push endpoints should be HTTPS; add validation to prevent insecure configs.

Apply after the existing push validation block:

+  # Push endpoint must be HTTPS
+  validation {
+    condition = alltrue([
+      for _, sub_config in var.instance.spec.push_subscriptions :
+      startswith(lower(sub_config.push_endpoint), "https://")
+    ])
+    error_message = "Push subscription push_endpoint must start with https://"
+  }

Also applies to: 34-41

🤖 Prompt for AI Agents
In modules/pubsub/default/1.0/variables.tf around lines 18-21 (and similarly for
lines 34-41), the push_endpoint field currently allows arbitrary URLs; add a
validation block that enforces HTTPS by checking that each push_endpoint starts
with "https://" (or use a regex that requires ^https://) and throw a meaningful
error message when the check fails; place this new validation immediately after
the existing push validation block for each map/object definition so insecure
(http://) endpoints are rejected at plan time.

Copy link
Contributor

@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

♻️ Duplicate comments (3)
modules/pubsub/default/1.0/facets.yaml (3)

22-33: Expose optional schema in facet to match schema.tf

schema.tf references spec.schema.*, but the facet has no schema block; this will break schema attachment/config. Add a toggleable schema object.

   properties:
     topic_name:
       type: string
@@
     topic_message_retention_duration:
       type: string
       title: Message Retention Duration
       description: How long to retain messages (e.g., '604800s' for 7 days)
       default: 604800s
+    schema:
+      type: object
+      title: Topic Schema (optional)
+      description: Configure a Pub/Sub schema and attach it to the topic
+      x-ui-toggle: true
+      properties:
+        name:
+          type: string
+          title: Schema Name
+          description: Schema ID; environment code will be suffixed
+        type:
+          type: string
+          title: Schema Type
+          enum: [AVRO, PROTOBUF]
+        definition:
+          type: string
+          title: Schema Definition
+          description: AVRO schema JSON or PROTO file contents
+        encoding:
+          type: string
+          title: Topic Encoding
+          enum: [JSON, BINARY]

43-49: Use integer type for ack_deadline_seconds (pull and push)

Provider expects an integer; this prevents float input slipping through validation.

             ack_deadline_seconds:
-              type: number
+              type: integer
@@
             ack_deadline_seconds:
-              type: number
+              type: integer

Also applies to: 65-71


56-71: Require push_endpoint for push subscriptions

Without a push_endpoint, the module can render invalid push subscriptions. Enforce via schema.

       patternProperties:
         ^[a-zA-Z0-9_-]+$:
           type: object
           title: Push Subscription Configuration
           properties:
             push_endpoint:
               type: string
               title: Push Endpoint
               description: The URL where messages will be pushed
             ack_deadline_seconds:
               type: integer
               title: Acknowledgment Deadline (seconds)
               description: Time before Pub/Sub attempts redelivery
               default: 20
               minimum: 10
               maximum: 600
+          required:
+            - push_endpoint
🧹 Nitpick comments (4)
modules/pubsub/default/1.0/facets.yaml (4)

41-49: Disallow unknown keys in subscription configs

Prevents typos silently passing validation.

         ^(?!goog)[A-Za-z][A-Za-z0-9._~+%-]{2,254}$:
           type: object
           title: Pull Subscription Configuration
+          additionalProperties: false
           properties:
@@
         ^(?!goog)[A-Za-z][A-Za-z0-9._~+%-]{2,254}$:
           type: object
           title: Push Subscription Configuration
+          additionalProperties: false
           properties:

Also applies to: 59-71


21-22: Lock top-level spec to known properties

Avoids stray/unsupported keys at top level.

   type: object
+  additionalProperties: false
   properties:

32-32: Quote duration scalars for consistency and parser safety

YAML plain scalars are fine, but quoting avoids edge cases and matches examples.

-      default: 604800s
+      default: "604800s"
@@
-    topic_message_retention_duration: 604800s
+    topic_message_retention_duration: "604800s"

Also applies to: 83-83


28-33: Optionally validate retention duration format and bounds

Pub/Sub accepts INTEGER with units (s/m/h/d), min 10m, max 31d. Consider a pattern and doc note. (cloud.google.com)

     topic_message_retention_duration:
       type: string
       title: Message Retention Duration
-      description: How long to retain messages (e.g., '604800s' for 7 days)
+      description: How long to retain messages (min 10m, max 31d). Valid forms: INTEGER[UNIT] where UNIT is s, m, h, or d (e.g., '604800s' for 7 days).
+      pattern: "^[0-9]+[smhd]$"
       default: "604800s"
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 38d4126 and 8329536.

📒 Files selected for processing (1)
  • modules/pubsub/default/1.0/facets.yaml (1 hunks)

Copy link
Contributor

@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: 0

♻️ Duplicate comments (4)
modules/pubsub/default/1.0/facets.yaml (4)

39-39: Tighten subscription name regex to Pub/Sub rules

Enforce start-with-letter, 3–255 chars, allowed chars, and not starting with "goog".

-        ^[a-zA-Z0-9_-]+$:
+        ^(?!goog)[A-Za-z][A-Za-z0-9._~+%-]{2,254}$:

Apply to both pull and push sections.

Also applies to: 57-57


12-16: Blocking: schema.tf is listed but facet exposes no schema config

schema.tf can’t work without spec.schema.*. Add a schema block to the facet.

@@
   properties:
@@
     topic_message_retention_duration:
       type: string
       title: Message Retention Duration
       description: How long to retain messages (e.g., '604800s' for 7 days)
       default: 604800s
+    schema:
+      type: object
+      title: Topic Schema (optional)
+      description: Configure a Pub/Sub schema and optionally attach it to the topic
+      x-ui-toggle: true
+      properties:
+        name:
+          type: string
+          title: Schema Name
+          description: Schema id; environment code will be suffixed
+        type:
+          type: string
+          title: Schema Type
+          enum: [AVRO, PROTOBUF]
+        definition:
+          type: string
+          title: Schema Definition
+          description: AVRO schema JSON or PROTO file contents
+        encoding:
+          type: string
+          title: Topic Encoding
+          enum: [JSON, BINARY]

Also applies to: 22-33


43-49: Use integer for ack_deadline_seconds

Provider expects an integer; prevent floats at the UI/schema layer.

             ack_deadline_seconds:
-              type: number
+              type: integer
@@
             ack_deadline_seconds:
-              type: number
+              type: integer

Also applies to: 66-71


56-71: Make push_endpoint required and enforce HTTPS

Push subscriptions without HTTPS endpoint will fail; validate early.

       patternProperties:
-        ^[a-zA-Z0-9_-]+$:
+        ^[a-zA-Z0-9_-]+$:
           type: object
           title: Push Subscription Configuration
           properties:
             push_endpoint:
               type: string
               title: Push Endpoint
-              description: The URL where messages will be pushed
+              description: The HTTPS URL where messages will be pushed
+              format: uri
+              pattern: '^https://'
             ack_deadline_seconds:
               type: integer
               title: Acknowledgment Deadline (seconds)
               description: Time before Pub/Sub attempts redelivery
               default: 20
               minimum: 10
               maximum: 600
+          required:
+            - push_endpoint
🧹 Nitpick comments (2)
modules/pubsub/default/1.0/facets.yaml (2)

28-33: Quote duration defaults and validate format

Ensure YAML parses as string and guard with a simple seconds+suffix pattern.

     topic_message_retention_duration:
       type: string
       title: Message Retention Duration
       description: How long to retain messages (e.g., '604800s' for 7 days)
-      default: 604800s
+      default: '604800s'
+      pattern: '^[0-9]+s$'
@@
-    topic_message_retention_duration: 604800s
+    topic_message_retention_duration: '604800s'

Also applies to: 84-84


23-27: Validate topic_name against Pub/Sub naming rules

Prevents late failures and enforces consistency.

     topic_name:
       type: string
       title: Topic Name
       description: Name for the Pub/Sub topic (will be suffixed with environment code)
       default: my-topic
+      pattern: '^(?!goog)[A-Za-z][A-Za-z0-9._~+%-]{2,254}$'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8329536 and 196483d.

📒 Files selected for processing (1)
  • modules/pubsub/default/1.0/facets.yaml (1 hunks)
🔇 Additional comments (1)
modules/pubsub/default/1.0/facets.yaml (1)

9-16: Consistency checks passed – all listed .tf files exist; schema is only configured in schema.tf per the default facet (no schema in topic.tf); and ack_deadline_seconds is handled in both subscription modules.

Copy link
Collaborator

@ishaankalra ishaankalra left a comment

Choose a reason for hiding this comment

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

give an input of cloud account


locals {
# Use environment's project automatically - no user input needed
project_id = null # Let Terraform use the default project from provider/environment
Copy link
Collaborator

Choose a reason for hiding this comment

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

take optional project id input from the cloud account

Copy link
Contributor

@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

♻️ Duplicate comments (1)
modules/pubsub/default/1.0/facets.yaml (1)

84-99: Make push_endpoint mandatory for push subscriptions.

Without push_endpoint, the module happily accepts invalid push subscription specs and Terraform fail-fast later. Add a required array so the facet enforces the contract upfront.

       patternProperties:
         ^[a-zA-Z0-9_-]+$:
           type: object
           title: Push Subscription Configuration
           properties:
             push_endpoint:
               type: string
               title: Push Endpoint
               description: The URL where messages will be pushed
             ack_deadline_seconds:
               type: integer
               title: Acknowledgment Deadline (seconds)
               description: Time before Pub/Sub attempts redelivery
               default: 20
               minimum: 10
               maximum: 600
+          required:
+            - push_endpoint
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc13117 and c869430.

📒 Files selected for processing (3)
  • modules/pubsub/default/1.0/facets.yaml (1 hunks)
  • modules/pubsub/default/1.0/main.tf (1 hunks)
  • modules/pubsub/default/1.0/variables.tf (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/pubsub/default/1.0/main.tf
  • modules/pubsub/default/1.0/variables.tf

description: Pull-based subscriptions where clients pull messages from Pub/Sub
x-ui-toggle: true
patternProperties:
^[a-zA-Z0-9_-]+$:
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Tighten subscription name regex to match Pub/Sub rules.

Current pattern allows invalid identifiers (e.g., leading digit, “goog*” prefixes) and rejects valid ones (e.g., containing ~). Mirror Google’s constraints so users don’t get runtime failures.

-        ^[a-zA-Z0-9_-]+$:
+        ^(?!goog)[A-Za-z][A-Za-z0-9._~+%-]{2,254}$:

Apply the same change to both pull and push subscription keys.

Also applies to: 85-85

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