Terraform for topics and subscriptions
The Terraform google provider works with lowtide through its Pub/Sub endpoint setting. Use a provider alias, so the same configuration can still manage resources in Pub/Sub.
provider "google" { alias = "lowtide" pubsub_custom_endpoint = "https://lowtide.pubsub.svc/v1/"}
resource "google_pubsub_topic" "orders" { provider = google.lowtide name = "orders"}
resource "google_pubsub_subscription" "orders_billing" { provider = google.lowtide name = "orders-billing" topic = google_pubsub_topic.orders.id ack_deadline_seconds = 30 filter = "attributes.region = \"eu\""
dead_letter_policy { dead_letter_topic = google_pubsub_topic.orders_dead_letter.id max_delivery_attempts = 5 }
retry_policy { minimum_backoff = "10s" maximum_backoff = "600s" }}After terraform apply, terraform plan shows no changes. lowtide returns resources in the shape the provider expects.
For a private CA, add the CA to the trust store of the machine that runs Terraform (Private CA).
IAM bindings
Section titled “IAM bindings”With Cloud IAM authorization on, the provider’s IAM resources work through lowtide too. lowtide forwards them to the shadow resource in Pub/Sub with your credentials.
resource "google_pubsub_topic_iam_member" "orders_publisher" { provider = google.lowtide topic = google_pubsub_topic.orders.name role = "roles/pubsub.publisher" member = "serviceAccount:orders-api@acme.iam.gserviceaccount.com"}
resource "google_pubsub_subscription_iam_binding" "billing_subscribers" { provider = google.lowtide subscription = google_pubsub_subscription.orders_billing.name role = "roles/pubsub.subscriber" members = ["serviceAccount:billing@acme.iam.gserviceaccount.com"]}You can also manage these bindings on the Pub/Sub resource directly, with the default provider. Both reach the same policy.
What is tested
Section titled “What is tested”Topics, subscriptions with filters, dead-letter policies, retry policies and push configs, and topic and subscription IAM resources, each followed by a terraform plan that must show no drift.
Not tested from Terraform yet: BigQuery and Cloud Storage subscription settings. They go through the same API handlers as gRPC, which are tested.
Not supported: google_pubsub_schema and topic schema settings.
The mirror label
Section titled “The mirror label”During a migration, the label lowtide-mirror = "pubsub" on a lowtide topic turns on mirroring to Pub/Sub. Removing it turns mirroring off.
resource "google_pubsub_topic" "orders" { provider = google.lowtide name = "orders" labels = { lowtide-mirror = "pubsub" }}