Skip to content

Commit

Permalink
feat: make granting service agent bigquery roles optional (#183)
Browse files Browse the repository at this point in the history
Signed-off-by: Antoine Deschênes <[email protected]>
  • Loading branch information
antoinedeschenes authored Apr 5, 2024
1 parent 74d94d6 commit 9508971
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ module "pubsub" {
| cloud\_storage\_subscriptions | The list of the Cloud Storage push subscriptions. | `list(map(string))` | `[]` | no |
| create\_subscriptions | Specify true if you want to create subscriptions. | `bool` | `true` | no |
| create\_topic | Specify true if you want to create a topic. | `bool` | `true` | no |
| grant\_bigquery\_project\_roles | Specify true if you want to add bigquery.metadataViewer and bigquery.dataEditor roles to the default Pub/Sub SA. | `bool` | `true` | no |
| grant\_token\_creator | Specify true if you want to add token creator role to the default Pub/Sub SA. | `bool` | `true` | no |
| message\_storage\_policy | A map of storage policies. Default - inherit from organization's Resource Location Restriction policy. | `map(any)` | `{}` | no |
| project\_id | The project ID to manage the Pub/Sub resources. | `string` | n/a | yes |
Expand Down
4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ resource "google_pubsub_schema" "schema" {
}

resource "google_project_iam_member" "bigquery_metadata_viewer_binding" {
count = length(var.bigquery_subscriptions) != 0 ? 1 : 0
count = var.grant_bigquery_project_roles && (length(var.bigquery_subscriptions) != 0) ? 1 : 0
project = var.project_id
role = "roles/bigquery.metadataViewer"
member = "serviceAccount:${local.pubsub_svc_account_email}"
}

resource "google_project_iam_member" "bigquery_data_editor_binding" {
count = length(var.bigquery_subscriptions) != 0 ? 1 : 0
count = var.grant_bigquery_project_roles && (length(var.bigquery_subscriptions) != 0) ? 1 : 0
project = var.project_id
role = "roles/bigquery.dataEditor"
member = "serviceAccount:${local.pubsub_svc_account_email}"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ variable "topic_kms_key_name" {
default = null
}

variable "grant_bigquery_project_roles" {
type = bool
description = "Specify true if you want to add bigquery.metadataViewer and bigquery.dataEditor roles to the default Pub/Sub SA."
default = true
}

variable "grant_token_creator" {
type = bool
description = "Specify true if you want to add token creator role to the default Pub/Sub SA."
Expand Down

0 comments on commit 9508971

Please sign in to comment.