Skip to content

How to transfer ownership of database to another role using Terraform resource? #2693

Answered by hongbo-miao
hongbo-miao asked this question in Q&A
Discussion options

You must be logged in to vote

This works to me.

https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_ownership

resource "snowflake_grant_ownership" "snowflake_transfer_database_ownership_to_role" {
  account_role_name  = "XXX_DB_ADMIN_ROLE"
  outbound_privileges = "REVOKE"
  on {
    object_type = "DATABASE"
    object_name = "XXX_DB"
  }
}

After changing ownership of database, now Terraform can never drop the database ☺️

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hongbo-miao
Comment options

Answer selected by hongbo-miao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant