https://github.com/tomarv2/terraform-google-pubsub
Terraform module for Google PubSub
https://github.com/tomarv2/terraform-google-pubsub
checkov google-cloud-platform google-pubsub terraform terraform-module
Last synced: about 1 year ago
JSON representation
Terraform module for Google PubSub
- Host: GitHub
- URL: https://github.com/tomarv2/terraform-google-pubsub
- Owner: tomarv2
- License: apache-2.0
- Created: 2021-03-13T05:11:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-03-28T19:15:48.000Z (over 4 years ago)
- Last Synced: 2025-03-22T15:49:52.685Z (over 1 year ago)
- Topics: checkov, google-cloud-platform, google-pubsub, terraform, terraform-module
- Language: HCL
- Homepage:
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Terraform module for Google PubSub
### Versions
- Module tested for Terraform 1.0.1.
- Google provider version [4.12.0](https://registry.terraform.io/providers/hashicorp/google/latest)
- `main` branch: Provider versions not pinned to keep up with Terraform releases
- `tags` releases: Tags are pinned with versions (use
in your releases)
### Usage
#### Option 1:
```
terrafrom init
terraform plan -var='teamid=tryme' -var='prjid=project1'
terraform apply -var='teamid=tryme' -var='prjid=project1'
terraform destroy -var='teamid=tryme' -var='prjid=project1'
```
**Note:** With this option please take care of remote state storage
#### Option 2:
##### Recommended method (stores remote state in remote backend(S3, Azure storage, or Google bucket) using `prjid` and `teamid` to create directory structure):
- Create python 3.8+ virtual environment
```
python3 -m venv
```
- Install package:
```
pip install tfremote --upgrade
```
- Set below environment variables:
```
export TF_GCLOUD_BUCKET=
export TF_GCLOUD_PREFIX=
export TF_GCLOUD_CREDENTIALS=
```
- Updated `examples` directory with required values.
- Run and verify the output before deploying:
```
tf -c=gcloud plan -var='teamid=foo' -var='prjid=bar'
```
- Run below to deploy:
```
tf -c=gcloud apply -var='teamid=foo' -var='prjid=bar'
```
- Run below to destroy:
```
tf -c=gcloud destroy -var='teamid=foo' -var='prjid=bar'
```
**Note:** Read more on [tfremote](https://github.com/tomarv2/tfremote)
##### PubSub Topic - pull & push subscription
```
terraform {
required_version = ">= 1.0.1"
required_providers {
google = {
source = "hashicorp/google"
version = "~> 4.12.0"
}
}
}
provider "google" {
region = var.region
project = var.project
}
module "pubsub" {
source = "../"
pull_subscriptions = [
{
name = "pull"
},
]
push_subscriptions = [
{
name = "push"
push_endpoint = "https://${var.project}.appspot.com/"
},
]
#-----------------------------------------------
# Note: Do not change teamid and prjid once set.
teamid = var.teamid
prjid = var.prjid
}
```
Please refer to examples directory [link](examples) for references.
## Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.0.1 |
| [google](#requirement\_google) | ~> 4.12.0 |
## Providers
| Name | Version |
|------|---------|
| [google](#provider\_google) | ~> 4.12.0 |
## Modules
No modules.
## Resources
| Name | Type |
|------|------|
| [google_pubsub_subscription.pull_subscriptions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource |
| [google_pubsub_subscription.push_subscriptions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_subscription) | resource |
| [google_pubsub_topic.topic](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/pubsub_topic) | resource |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [create\_topic](#input\_create\_topic) | Specify true if you want to create a topic | `bool` | `true` | no |
| [default\_ack\_deadline\_seconds](#input\_default\_ack\_deadline\_seconds) | Default ack deadline in seconds | `string` | `"10"` | no |
| [message\_storage\_policy](#input\_message\_storage\_policy) | A map of storage policies. Default - inherit from organization's Resource Location Restriction policy. | `map(any)` | `{}` | no |
| [prjid](#input\_prjid) | Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply' | `string` | n/a | yes |
| [pull\_subscriptions](#input\_pull\_subscriptions) | The list of the pull subscriptions | `list(map(string))` | `[]` | no |
| [push\_subscriptions](#input\_push\_subscriptions) | The list of the push subscriptions | `list(map(string))` | `[]` | no |
| [teamid](#input\_teamid) | Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply' | `string` | n/a | yes |
| [topic\_kms\_key\_name](#input\_topic\_kms\_key\_name) | The resource name of the Cloud KMS CryptoKey to be used to protect access to messages published on this topic. | `string` | `null` | no |
| [topic\_name](#input\_topic\_name) | The Pub/Sub topic name | `string` | `null` | no |
## Outputs
| Name | Description |
|------|-------------|
| [pubsub\_pull\_message\_retention](#output\_pubsub\_pull\_message\_retention) | PubSub pull subscription retention |
| [pubsub\_pull\_subscription\_id](#output\_pubsub\_pull\_subscription\_id) | PubSub pull subscription id |
| [pubsub\_pull\_subscription\_name](#output\_pubsub\_pull\_subscription\_name) | PubSub pull subscription name |
| [pubsub\_push\_message\_retention](#output\_pubsub\_push\_message\_retention) | PubSub push subscription retention |
| [pubsub\_push\_subscription\_id](#output\_pubsub\_push\_subscription\_id) | PubSub push subscription id |
| [pubsub\_push\_subscription\_name](#output\_pubsub\_push\_subscription\_name) | PubSub push subscription name |
| [pubsub\_topic\_id](#output\_pubsub\_topic\_id) | PubSub topic id |
| [pubsub\_topic\_name](#output\_pubsub\_topic\_name) | PubSub topic name |
| [pubsub\_topic\_project](#output\_pubsub\_topic\_project) | PubSub topic project |