-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow creating subscriptions without creating topic (#72)
BREAKING CHANGE: The `create_subscriptions` variable is now used to control whether subscriptions should be created. Set `create_subscriptions = false` *and* `create_topic = false` if you don't want the module to do anything.
- Loading branch information
Showing
8 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Simple Example - Creates Subscriptions Only | ||
|
||
This example illustrates how to use the `pubsub` module to create only subscriptions. | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| project\_id | The project ID to manage the Pub/Sub resources | `string` | n/a | yes | | ||
| topic\_project | The project ID of the topic | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| project\_id | The project ID | | ||
| topic\_labels | The labels of the Pub/Sub topic created | | ||
| topic\_name | The name of the Pub/Sub topic created | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
|
||
## Requirements | ||
|
||
The following sections describe the requirements which must be met in | ||
order to invoke this example. The requirements of the | ||
[root module][root-module-requirements] must be met. | ||
|
||
## Usage | ||
|
||
To provision this example, populate `terraform.tfvars` with the [required variables](#inputs) and run the following commands within | ||
this directory: | ||
- `terraform init` to get the plugins | ||
- `terraform plan` to see the infrastructure plan | ||
- `terraform apply` to apply the infrastructure build | ||
- `terraform destroy` to destroy the built infrastructure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
provider "google" { | ||
version = "~> 3.51" | ||
region = "us-central1" | ||
} | ||
|
||
resource "google_pubsub_topic" "example" { | ||
name = "terraform-test-topic" | ||
project = var.topic_project | ||
|
||
} | ||
module "pubsub" { | ||
source = "../../" | ||
project_id = var.project_id | ||
create_topic = false | ||
create_subscriptions = true | ||
topic = google_pubsub_topic.example.id | ||
|
||
|
||
pull_subscriptions = [ | ||
{ | ||
name = "pull" | ||
ack_deadline_seconds = 10 | ||
}, | ||
] | ||
|
||
push_subscriptions = [ | ||
{ | ||
name = "push" | ||
push_endpoint = "https://${var.project_id}.appspot.com/" | ||
x-goog-version = "v1beta1" | ||
ack_deadline_seconds = 20 | ||
expiration_policy = "1209600s" // two weeks | ||
}, | ||
] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "project_id" { | ||
value = var.project_id | ||
description = "The project ID" | ||
} | ||
|
||
output "topic_name" { | ||
value = module.pubsub.topic | ||
description = "The name of the Pub/Sub topic created" | ||
} | ||
|
||
output "topic_labels" { | ||
value = module.pubsub.topic_labels | ||
description = "The labels of the Pub/Sub topic created" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2018 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
type = string | ||
description = "The project ID to manage the Pub/Sub resources" | ||
} | ||
|
||
variable "topic_project" { | ||
type = string | ||
description = "The project ID of the topic" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters