Skip to content

Commit 62ae776

Browse files
feat: Add subscriber_id variable to override the generated ID for the subscriber (#84)
1 parent 0e12c9f commit 62ae776

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

modules/pubsub/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ so that all dependencies are met.
4242
| log\_sink\_writer\_identity | The service account that logging uses to write log entries to the destination. (This is available as an output coming from the root module). | `string` | n/a | yes |
4343
| project\_id | The ID of the project in which the pubsub topic will be created. | `string` | n/a | yes |
4444
| push\_endpoint | The URL locating the endpoint to which messages should be pushed. | `string` | `""` | no |
45+
| subscriber\_id | The ID to give the pubsub pull subscriber service account (optional). | `string` | `""` | no |
4546
| subscription\_labels | A set of key/value label pairs to assign to the pubsub subscription. | `map(string)` | `{}` | no |
4647
| topic\_labels | A set of key/value label pairs to assign to the pubsub topic. | `map(string)` | `{}` | no |
4748
| topic\_name | The name of the pubsub topic to be created and used for log entries matching the filter. | `string` | n/a | yes |

modules/pubsub/main.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ locals {
3232
concat(google_pubsub_subscription.pubsub_push_subscription.*.id, [""]),
3333
0,
3434
)
35+
subscriber_id = var.subscriber_id == "" ? "${local.topic_name}-subscriber" : var.subscriber_id
3536
}
3637

3738
#----------------#
@@ -67,7 +68,7 @@ resource "google_pubsub_topic_iam_member" "pubsub_sink_member" {
6768
#-----------------------------------------------#
6869
resource "google_service_account" "pubsub_subscriber" {
6970
count = var.create_subscriber ? 1 : 0
70-
account_id = "${local.topic_name}-subscriber"
71+
account_id = local.subscriber_id
7172
display_name = "${local.topic_name} Topic Subscriber"
7273
project = var.project_id
7374
}

modules/pubsub/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ variable "create_subscriber" {
2020
default = false
2121
}
2222

23+
variable "subscriber_id" {
24+
description = "The ID to give the pubsub pull subscriber service account (optional)."
25+
type = string
26+
default = ""
27+
}
28+
2329
variable "subscription_labels" {
2430
type = map(string)
2531
default = {}

0 commit comments

Comments
 (0)