Skip to content

Instantly share code, notes, and snippets.

@onelharrison
Last active January 18, 2022 16:34
Show Gist options
  • Save onelharrison/536a400ec658e4133d03e37836e9ed88 to your computer and use it in GitHub Desktop.
Save onelharrison/536a400ec658e4133d03e37836e9ed88 to your computer and use it in GitHub Desktop.
resource "snowflake_procedure" "backup_database" {
provider = snowflake.sys_admin
name = "SPROC_BACKUP_DATABASE"
database = snowflake_database.sandbox.name
schema = snowflake_schema.sandbox_tools.name
arguments {
name = "DATABASE"
type = "VARCHAR"
}
comment = "Procedure for backing up a database to S3"
return_type = "VARCHAR"
execute_as = "CALLER"
return_behavior = "IMMUTABLE"
null_input_behavior = "RETURNS NULL ON NULL INPUT"
statement = file("${path.module}/stored_procedures/sproc_backup_database.js")
}
resource "snowflake_procedure_grant" "usage_sproc_backup_database" {
provider = snowflake.security_admin
database_name = snowflake_database.sandbox.name
schema_name = snowflake_schema.sandbox_tools.name
procedure_name = snowflake_procedure.backup_database.name
arguments {
name = "DATABASE"
type = "VARCHAR"
}
return_type = "VARCHAR"
privilege = "USAGE"
roles = [
snowflake_role.sandbox_rw.name
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment