This module makes it easy to create Google Cloud Pub/Sub topic and subscriptions associated with the topic.
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
}
]
}
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 |
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 |
In order to execute this module you must have a Service Account with the following:
roles/pubsub.editor
In order to operate with the Service Account you must activate the following APIs on the project where the Service Account was created:
You can pass the service account credentials into this module by setting the following environment variables:
GOOGLE_CREDENTIALS
GOOGLE_CLOUD_KEYFILE_JSON
GCLOUD_KEYFILE_JSON
See more details.
$ make generate_docs
The integration tests for this module leverage kitchen-terraform and kitchen-inspec.
You must set up by manually before running the integration test:
test/fixtures/terraform.tfvars.sample
to test/fixtures/terraform.tfvars
.The tests will do the following:
bundle install
command
test-kitchen
, kitchen-terraform
and kitchen-inspec
bundle exec kitchen create
command
terraform init
bundle exec kitchen converge
command
terraform apply -auto-approve
bundle exec kitchen verify
command
bundle exec kitchen destroy
command
terraform destroy -force
You can use the following command to run the integration test in the root directory.
$ make test_integration
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:
pip install flake8
terraform validate
command.