-
I'm using VCS using Azure DevOps repos and want to switch roles by overriding the environment variable (SNOWFLAKE_ROLE). What is the best way to do this if I've configured VCS with my Terraform Cloud. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I solved the problem by not declaring the SNOWFLAKE_ROLE as my environment or TF variable. Instead , I used used provider config in every single terraform file with an alias . The provider config would switch the role . eg : provider "snowflake" { role = "USERADMIN" } resource "snowflake_role" "role" { filename : databases.tf provider "snowflake" { role = "SYSADMIN" } resource "snowflake_database" "database" { |
Beta Was this translation helpful? Give feedback.
-
Resolved |
Beta Was this translation helpful? Give feedback.
I solved the problem by not declaring the SNOWFLAKE_ROLE as my environment or TF variable. Instead , I used used provider config in every single terraform file with an alias . The provider config would switch the role .
eg :
filename : roles.tf
provider "snowflake" {
role = "USERADMIN"
alias = "useradmin"
}
resource "snowflake_role" "role" {
provider = snowflake.useradmin
name = "DEVELOPER_ROLE"
comment = "Developer role for Service accounts"
}
filename : databases.tf
provider "snowflake" {
role = "SYSADMIN"
alias = "sysadmin"
}
resource "snowflake_database" "database" {
provider = snowflake.sysadmin
name = "SALES_DB"
comment = "Sales database"
}