Skip to content

Commit 0e44fc6

Browse files
authored
feat: Add submodules for pub and sub (#234)
1 parent fcc6f01 commit 0e44fc6

31 files changed

Lines changed: 2020 additions & 1 deletion

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ docker_generate_docs:
8080
-e ENABLE_BPMETADATA='1' \
8181
-v "$(CURDIR)":/workspace \
8282
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
83-
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
83+
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs display'
8484

8585
# Alias for backwards compatibility
8686
.PHONY: generate_docs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Bigquery Example
2+
3+
This example illustrates how to use the `pub` amd `sub` module.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes |
11+
12+
## Outputs
13+
14+
| Name | Description |
15+
|------|-------------|
16+
| project\_id | The project ID |
17+
| topic\_labels | The labels of the Pub/Sub topic created |
18+
| topic\_name | The name of the Pub/Sub topic created |
19+
20+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
21+
22+
## Requirements
23+
24+
The following sections describe the requirements which must be met in
25+
order to invoke this example. The requirements of the
26+
[root module][root-module-requirements] must be met.
27+
28+
## Usage
29+
30+
To provision this example, populate `terraform.tfvars` with the [required variables](#inputs) and run the following commands within
31+
this directory:
32+
- `terraform init` to get the plugins
33+
- `terraform plan` to see the infrastructure plan
34+
- `terraform apply` to apply the infrastructure build
35+
- `terraform destroy` to destroy the built infrastructure
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
provider "google" {
18+
region = "europe-west1"
19+
}
20+
21+
module "pub" {
22+
source = "terraform-google-modules/pubsub/google//modules/pub"
23+
version = "~> 7.0"
24+
25+
project_id = var.project_id
26+
topic = "cft-tf-pub-topic-bigquery"
27+
topic_labels = {
28+
foo_label = "foo_value"
29+
bar_label = "bar_value"
30+
}
31+
}
32+
33+
module "sub" {
34+
source = "terraform-google-modules/pubsub/google//modules/sub"
35+
version = "~> 7.0"
36+
37+
project_id = var.project_id
38+
topic = "cft-tf-pub-topic-bigquery"
39+
40+
bigquery_subscriptions = [
41+
{
42+
name = "sub_example_subscription"
43+
table = "${var.project_id}:sub_example_dataset.sub_example_table"
44+
},
45+
]
46+
47+
depends_on = [
48+
google_bigquery_table.test
49+
]
50+
51+
}
52+
53+
resource "google_bigquery_dataset" "test" {
54+
project = var.project_id
55+
dataset_id = "sub_example_dataset"
56+
location = "europe-west1"
57+
}
58+
59+
resource "google_bigquery_table" "test" {
60+
project = var.project_id
61+
deletion_protection = false
62+
table_id = "sub_example_table"
63+
dataset_id = google_bigquery_dataset.test.dataset_id
64+
65+
schema = <<EOF
66+
[
67+
{
68+
"name": "data",
69+
"type": "STRING",
70+
"mode": "NULLABLE",
71+
"description": "The data"
72+
}
73+
]
74+
EOF
75+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "project_id" {
18+
value = var.project_id
19+
description = "The project ID"
20+
}
21+
22+
output "topic_name" {
23+
value = module.pub.topic
24+
description = "The name of the Pub/Sub topic created"
25+
}
26+
27+
output "topic_labels" {
28+
value = module.pub.topic_labels
29+
description = "The labels of the Pub/Sub topic created"
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
type = string
19+
description = "The project ID to manage the Pub/Sub resources"
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Cloud Storage Example
2+
3+
This example illustrates how to use the `pub` and `sub` module.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes |
11+
12+
## Outputs
13+
14+
| Name | Description |
15+
|------|-------------|
16+
| bucket\_name | The name of the Cloud Storage bucket created |
17+
| project\_id | The project ID |
18+
| topic\_name | The name of the Pub/Sub topic created |
19+
20+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
21+
22+
## Requirements
23+
24+
The following sections describe the requirements which must be met in
25+
order to invoke this example. The requirements of the
26+
[root module][root-module-requirements] must be met.
27+
28+
## Usage
29+
30+
To provision this example, populate `terraform.tfvars` with the [required variables](#inputs) and run the following commands within
31+
this directory:
32+
- `terraform init` to get the plugins
33+
- `terraform plan` to see the infrastructure plan
34+
- `terraform apply` to apply the infrastructure build
35+
- `terraform destroy` to destroy the built infrastructure
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Copyright 2018-2023 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
resource "random_id" "bucket_suffix" {
18+
byte_length = 4
19+
}
20+
21+
provider "google" {
22+
region = "europe-west1"
23+
}
24+
25+
module "pub" {
26+
source = "terraform-google-modules/pubsub/google//modules/pub"
27+
version = "~> 7.0"
28+
29+
project_id = var.project_id
30+
topic = "cft-tf-pub-topic-cloud-storage"
31+
32+
topic_labels = {
33+
foo_label = "foo_value"
34+
}
35+
}
36+
37+
module "sub" {
38+
source = "terraform-google-modules/pubsub/google//modules/sub"
39+
version = "~> 7.0"
40+
41+
project_id = var.project_id
42+
topic = "cft-tf-pub-topic-cloud-storage"
43+
44+
cloud_storage_subscriptions = [
45+
{
46+
name = "sub_example_bucket_subscription"
47+
bucket = google_storage_bucket.test.name
48+
49+
filename_prefix = "example_prefix_"
50+
filename_suffix = "_example_suffix"
51+
filename_datetime_format = "YYYY-MM-DD/hh_mm_ssZ"
52+
ack_deadline_seconds = 300
53+
},
54+
]
55+
}
56+
57+
resource "google_storage_bucket" "test" {
58+
project = var.project_id
59+
name = join("-", ["sub_test_bucket", random_id.bucket_suffix.hex])
60+
location = "europe-west1"
61+
uniform_bucket_level_access = true
62+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2018-2023 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "project_id" {
18+
value = var.project_id
19+
description = "The project ID"
20+
}
21+
22+
output "bucket_name" {
23+
value = google_storage_bucket.test.name
24+
description = "The name of the Cloud Storage bucket created"
25+
}
26+
27+
output "topic_name" {
28+
value = module.pub.topic
29+
description = "The name of the Pub/Sub topic created"
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
type = string
19+
description = "The project ID to manage the Pub/Sub resources"
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Simple Example
2+
3+
This example illustrates how to use the `pub` and `sub` module.
4+
5+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+
## Inputs
7+
8+
| Name | Description | Type | Default | Required |
9+
|------|-------------|------|---------|:--------:|
10+
| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes |
11+
12+
## Outputs
13+
14+
| Name | Description |
15+
|------|-------------|
16+
| project\_id | The project ID |
17+
| topic\_labels | The labels of the Pub/Sub topic created |
18+
| topic\_name | The name of the Pub/Sub topic created |
19+
20+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
21+
22+
## Requirements
23+
24+
The following sections describe the requirements which must be met in
25+
order to invoke this example. The requirements of the
26+
[root module][root-module-requirements] must be met.
27+
28+
## Usage
29+
30+
To provision this example, populate `terraform.tfvars` with the [required variables](#inputs) and run the following commands within
31+
this directory:
32+
- `terraform init` to get the plugins
33+
- `terraform plan` to see the infrastructure plan
34+
- `terraform apply` to apply the infrastructure build
35+
- `terraform destroy` to destroy the built infrastructure

0 commit comments

Comments
 (0)