Skip to content

cloudchacho/terraform-google-hedwig-topic

Repository files navigation

Hedwig Topic Terraform module

Hedwig is a inter-service communication bus that works on Google Pub/Sub, while keeping things pretty simple and straight forward. It uses json schema draft v4 for schema validation so all incoming and outgoing messages are validated against pre-defined schema.

This module provides a custom Terraform modules for deploying Hedwig infrastructure that creates Hedwig topics.

Usage

module "topic-dev-user-updated" {
  source = "cloudchacho/hedwig-topic/google"
  topic  = "dev-user-updated-v1"
}

It's recommended that topic include your environment, as well as a major version for the message schema. For example, JSON Schema is a good way to version message content while also keeping it human-readable.

Naming convention - lowercase alphanumeric and dashes only. The Pub/Sub topic name will be prefixed by hedwig-.

Please note Google's restrictions (if not followed, errors may be confusing and often totally wrong):

Firehose

To firehose—read as, save—messages to Google Cloud Storage (GCS), use the firehose_config setting like the following example illustrates:

module "topic-dev-user-updated" {
  source = "cloudchacho/hedwig-topic/google"
  topic  = "dev-user-updated-v1"
  firehose_config = {
    enabled = true
    bucket = "mybucket"
  }
}

The result will be an additional Pub/Sub Cloud Storage subscription that saves messages to GCS.

Naming convention - The additional subscription has hedwig- prefix and -firehose suffix; for example, the earlier example creates a hedwig-dev-user-updated-v1 topic and hedwig-dev-user-updated-v1-firehose subscription. See caveats for GCS bucket creation and Identity and Access Management (IAM) permissions prerequisites.

Caveats

GCS and IAM

If you're using the firehose_config setting to save messages to a Google Cloud Storage (GCS) bucket, then do the following GCS and Identity and Access Management (IAM) tasks before applying:

  1. Create your GCS bucket.
  2. Configure IAM permissions. This is a complicated task where you choose to grant permissions at either the bucket level or project level; for details, see Assign Cloud Storage roles to the Pub/Sub service account Google docs page.

Release Notes

GitHub Releases

How to publish

Go to Terraform Registry, and Resync module.