Skip to content

feat(gcp): add support for verifying Pub/Sub Topics and Subscriptions#1680

Merged
james00012 merged 1 commit intogruntwork-io:mainfrom
Amit2465:ay/feat-add-gcp-pubsub-support
Apr 2, 2026
Merged

feat(gcp): add support for verifying Pub/Sub Topics and Subscriptions#1680
james00012 merged 1 commit intogruntwork-io:mainfrom
Amit2465:ay/feat-add-gcp-pubsub-support

Conversation

@Amit2465
Copy link
Copy Markdown
Contributor

@Amit2465 Amit2465 commented Mar 8, 2026

Description

This PR adds support for Google Cloud Pub/Sub to the GCP module. It introduces helper functions to verify the existence of Pub/Sub Topics and Subscriptions, along with a complete Terraform example and automated integration tests.

This is a new feature addition and does not introduce any backward-incompatible changes.

TODOs

Read the Gruntwork contribution guidelines.

  • Update the docs.
  • Run the relevant tests successfully, including pre-commit checks.
  • Ensure any 3rd party code adheres with our license policy or delete this line if its not applicable.
  • Include release notes. If this PR is backward incompatible, include a migration guide.
  • Make a plan for release of the functionality in this PR. If it delivers value to an end user, you are responsible for ensuring it is released promptly, and correctly. If you are not a maintainer, you are responsible for finding a maintainer to do this for you.

Release Notes (draft)

Added support for verifying Google Cloud Pub/Sub Topics and Subscriptions in the GCP module.

Migration Guide

No backward incompatible changes were introduced.


Verification Results

I have verified this PR locally against a real GCP project:

  • Linting: Passed using golangci-lint run.
  • Formatting: Passed go fmt and terraform fmt.
  • Integration Test: Successfully ran TestTerraformGcpPubSubExample.

Test Output Snippet:

=== RUN   TestTerraformGcpPubSubExample
...
TestTerraformGcpPubSubExample 2026-03-08T16:21:20 logger.go:67: Verifying Pub/Sub topic pubsub-topic-mt4hzw exists in project amith-1772452782257
TestTerraformGcpPubSubExample 2026-03-08T16:21:21 logger.go:67: Verifying Pub/Sub subscription pubsub-sub-fzusep exists in project amith-1772452782257
...
--- PASS: TestTerraformGcpPubSubExample (49.30s)
PASS

@Amit2465 Amit2465 force-pushed the ay/feat-add-gcp-pubsub-support branch from 6629204 to 10be290 Compare March 9, 2026 14:02
@james00012
Copy link
Copy Markdown
Contributor

james00012 commented Mar 23, 2026

A couple of minor, non-blocking suggestions: The strings.ToLower() calls in the test (lines 31-32) are unnecessary since random.UniqueId() already returns lowercase strings. You can drop those and the "strings" import.

Also, it'd be nice to see a negative test case (e.g., asserting that a non-existent topic returns an error), though that can be a follow-up. The Terraform version comment in main.tf saying "only being tested with 0.13.x" is stale, but that's consistent with other examples in the repo so not worth blocking on.

Overall this looks good to merge.

james00012
james00012 previously approved these changes Mar 23, 2026
Copy link
Copy Markdown
Contributor

@james00012 james00012 left a comment

Choose a reason for hiding this comment

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

LGTM

@james00012
Copy link
Copy Markdown
Contributor

You probably need to rebase the change anyway so if you can address those minor comments, it would be great.

@james00012
Copy link
Copy Markdown
Contributor

You probably need to rebase the change anyway so if you can address those minor comments, it would be great.

Friendly ping in order for us to merge this change @Amit2465 .

@Amit2465 Amit2465 force-pushed the ay/feat-add-gcp-pubsub-support branch from 10be290 to 6785de0 Compare March 30, 2026 06:03
- Added AssertTopicExists and AssertTopicExistsE to modules/gcp
- Added AssertSubscriptionExists and AssertSubscriptionExistsE to modules/gcp
- Created integration test fixture in examples/terraform-gcp-pubsub-example
- Added automated test TestTerraformGcpPubSubExample in test/gcp
@Amit2465
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback! Here's what was addressed:

  • Removed the strings.ToLower() no-op calls and the unused strings import.
  • Added negative test cases for both topic and subscription in modules/gcp/pubsub_test.go.
  • Migrated to context-aware function signatures following the existing GCP module conventions.
  • Rebased against main.

@james00012
Copy link
Copy Markdown
Contributor

Thanks for addressing all the feedback, this looks good to merge. One minor note: TestAssertTopicAndSubscriptionExist largely duplicates TestAssertSubscriptionExistsNoFalseNegative; consider folding the subscription-topic linkage check into that test and dropping the duplicate. Not a blocker though. LGTM.

Copy link
Copy Markdown
Contributor

@james00012 james00012 left a comment

Choose a reason for hiding this comment

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

LGTM

@james00012 james00012 merged commit 01a663c into gruntwork-io:main Apr 2, 2026
2 checks 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.

2 participants