openinfrastructure / terraform-google-pubsub

This module makes it easy to create Google Cloud Pub/Sub topic and subscriptions associated with the topic.
https://registry.terraform.io/modules/terraform-google-modules/pubsub/google
Apache License 2.0
0 stars 1 forks source link

terraform-google-pubsub

This module makes it easy to create Google Cloud Pub/Sub topic and subscriptions associated with the topic.

Usage

This is a simple usage of the module. Please see also a simple setup provided in the example directory.

module "pubsub" {
  source  = "terraform-google-modules/pubsub/google"
  version = "~> 0.2.0"

  topic              = "tf-topic"
  project_id         = "my-pubsub-project"
  push_subscriptions = [
    {
      name                 = "push"   // required
      ack_deadline_seconds = 20 // optional
      push_endpoint        = "https://example.com" // required
      x-goog-version       = "v1beta1" // optional
    }
  ]
  pull_subscriptions = [
    {
      name                 = "pull" // required
      ack_deadline_seconds = 20 // optional
    }
  ]
}

Inputs

Name Description Type Default Required
project_id The project ID to manage the Pub/Sub resources string - yes
pull_subscriptions The list of the pull subscriptions list <list> no
push_subscriptions The list of the push subscriptions list <list> no
topic The Pub/Sub topic name string - yes

Outputs

Name Description
id The ID of the Pub/Sub topic
subscription_names The name list of Pub/Sub subscriptions
subscription_paths The path list of Pub/Sub subscriptions
topic The name of the Pub/Sub topic
uri The URI of the Pub/Sub topic

Requirements

Installation Dependencies

Configure a Service Account

In order to execute this module you must have a Service Account with the following:

Roles

Enable APIs

In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:

Service Account Credentials

You can pass the service account credentials into this module by setting the following environment variables:

See more details.

Testing

Requirements

Generate docs automatically

$ make generate_docs

Integration Test

The integration tests for this module leverage kitchen-terraform and kitchen-inspec.

You must set up by manually before running the integration test:

The tests will do the following:

You can use the following command to run the integration test in the root directory.

$ make test_integration

Linting

The makefile in this project will lint or sometimes just format any shell, Python, golang, Terraform, or Dockerfiles. The linters will only be run if the makefile finds files with the appropriate file extension.

All of the linter checks are in the default make target, so you just have to run

$ make -s

The -s is for 'silent'. Successful output looks like this

Running shellcheck
Running flake8
Running go fmt and go vet
Running terraform validate
Running terraform fmt
Running hadolint on Dockerfiles
Checking for required files
The following lines have trailing whitespace
Generating markdown docs with terraform-docs

The linters are as follows: