This file contains hidden or 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
| - Role: Admin_Role | |
| Users: | |
| - Usename1 | |
| - Username2 | |
| - Username3 | |
| - Role: Developer_Role | |
| Users: | |
| - Usename4 | |
| - Username5 |
This file contains hidden or 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
| - grant: | |
| grant_resource_name: "schema" | |
| role_name: "${user_role_name}" | |
| privilege: | |
| - "MONITOR" | |
| - "USAGE" | |
| - "ADD SEARCH OPTIMIZATION" | |
| - grant: | |
| grant_resource_name: "schema" | |
| role_name: "${admin_role_name}" |
This file contains hidden or 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
| provider "snowflake" { | |
| // required | |
| username = "..." | |
| account = "..." | |
| region = "..." | |
| // optional, at exactly one must be set | |
| password = "..." | |
| oauth_access_token = "..." | |
| private_key_path = "..." |
This file contains hidden or 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
| resource snowflake_database_grant grant_database { | |
| count = var.database_resource | |
| database_name = var.database_name | |
| privilege = var.privileges | |
| roles = [var.role_name] | |
| with_grant_option = false | |
| } | |
| resource snowflake_schema_grant grant_schema { | |
| count = var.schema_resource |
This file contains hidden or 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
| module "snowflake_role_grants" { | |
| source = "../snowflake_role_grants" | |
| database_name = var.database_name | |
| warehouse_name = var.warehouse_name | |
| stage_name = var.stage_name | |
| schema_name = var.schema_name | |
| role_name = var.role_name | |
| privileges = var.privileges | |
| file_format = var.file_format_name | |
| database_resource = 0 |
This file contains hidden or 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
| module "snowflake_role_grants" { | |
| source = "../snowflake_role_grants" | |
| database_name = var.database_name | |
| warehouse_name = var.warehouse_name | |
| stage_name = var.stage_name | |
| schema_name = var.schema_name | |
| role_name = var.role_name | |
| privileges = var.privileges | |
| file_format = var.file_format_name | |
| database_resource = 1 |
This file contains hidden or 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
| resource "snowflake_schema_grant" "grant" { | |
| for_each = { for entry in local.config_privileges : "${entry.grant_resource_name}.${entry.role_name}.${entry.privileges}" => entry } | |
| database_name = var.database_name | |
| schema_name = var.schema_name | |
| privilege = each.privilege | |
| roles = [each.role_name] | |
| with_grant_option = false | |
| } |
This file contains hidden or 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
| locals { | |
| grant_config = yamldecode(templatefile("role_permissions.yaml", { | |
| user_role_name = "user role name" | |
| admin_role_name = "admin role name" | |
| })) | |
| config_privileges = distinct(flatten([ | |
| for each_grant in local.grant_config : [ | |
| for privilege in each_grant.privilege : { | |
| grant_resource_name = each_grant.grant_resource_name |
This file contains hidden or 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
| - grant: | |
| grant_resource_name: "schema" | |
| role_name: "${user_role_name}" | |
| privilege: | |
| - "MONITOR" | |
| - "USAGE" | |
| - "ADD SEARCH OPTIMIZATION" | |
| - grant: | |
| grant_resource_name: "schema" | |
| role_name: "${admin_role_name}" |
This file contains hidden or 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
| locals { | |
| grant_config = yamldecode(templatefile("role_permissions.yaml", { | |
| user_role_name = "user role name" | |
| admin_role_name = "admin role name" | |
| })) | |
| config_privileges = distinct(flatten([ | |
| for each_grant in local.grant_config : [ | |
| for privilege in each_grant.privilege : { | |
| grant_resource_name = each_grant.grant_resource_name |
NewerOlder