Skip to content

Commit

Permalink
Add database usage variable to application_database
Browse files Browse the repository at this point in the history
  • Loading branch information
stkbailey committed Sep 29, 2021
1 parent 7693974 commit 29fa31f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/application_database/privileges.tf
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ resource "snowflake_database_grant" "read" {

database_name = snowflake_database.app.name
privilege = each.key
roles = local.all_read_roles
roles = concat(
local.all_read_roles,
var.grant_database_usage_to_roles
)
}

resource "snowflake_schema_grant" "read" {
Expand All @@ -90,7 +93,10 @@ resource "snowflake_schema_grant" "public_read" {
database_name = snowflake_database.app.name
schema_name = local.public_schema_name
privilege = each.key
roles = local.all_read_roles
roles = concat(
local.all_read_roles,
var.grant_database_usage_to_roles
)
}

resource "snowflake_table_grant" "read" {
Expand Down
6 changes: 6 additions & 0 deletions modules/application_database/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ variable "grant_read_to_users" {
type = list(string)
}

variable "grant_database_usage_to_roles" {
default = []
description = "Additional roles that should have only the USAGE privilege on the module database. This allows sub-resources to be granted individually by the admin role."
type = list(string)
}

variable "reader_role_name_suffix" {
default = "_READER"
description = "The suffix appended to the database name to determine the reader role (e.g. APP_READER)."
Expand Down

0 comments on commit 29fa31f

Please sign in to comment.