-
Notifications
You must be signed in to change notification settings - Fork 428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SET MASKING POLICY resources #1719
Comments
Set masking policy resources could utilize block list too just like snowflake_table
|
Hi @TerjeRusska, thanks for submitting this issue. As you suggest, it sounds like there's a need for being able to apply masking policies to columns separately from table creation and with a different role. Your suggestion to create a separate resource to manage policy applications makes sense and actually aligns with our plan to revamp the table resource (and fix the long standing issue #753). Our current thinking is to implement a new masking policy application resource that could be used like so: # Default provider for most resources
provider "snowflake" {
role = "TF_ROLE"
}
# Alternative provider with masking_admin role
provider "snowflake" {
alias = "masking"
role = "MASKING_ADMIN"
}
resource "snowflake_masking_policy" "policy" {
provider = snowflake.masking # Create masking policy with masking_admin role
name = "EXAMPLE_MASKING_POLICY"
database = "EXAMPLE_DB"
schema = "EXAMPLE_SCHEMA"
value_data_type = "string"
masking_expression = "case when current_role() in ('ANALYST') then val else sha2(val, 512) end"
return_data_type = "string"
}
# Table is created by the default provider
resource "snowflake_table" "table" {
database = "EXAMPLE_DB"
schema = "EXAMPLE_SCHEMA"
name = "table"
column {
name = "age"
type = "int"
}
}
# Proposed new resource
resource "snowflake_table_column_masking_view_application" "application" {
provider = snowflake.masking # Apply masking policy with masking_admin role
table = snowflake_table.table.qualified_name
column = "age"
masking_policy = snowflake_masking_policy.policy.qualified_name
} With that setup you should be able to finely control which role has table ownership and which role creates and applies masking policy. Would that resolve your issue? |
Hi @sfc-gh-ngaberel Yes this functionality is what we're looking for. Have you looked into the block list method as well? I think it would keep the overall state resource count down if they are grouped together on table level and not have for every column separately. |
Hi @TerjeRusska, the new resource has been merged in main (cf. #1739) and will be available in the next release of the provider (this week or next probably). |
@TerjeRusska We just released v0.63 with the new resource, feel free to upgrade! |
@sfc-gh-ngaberel I have implemented this resource for a test run, first thing I noticed is that when setting the table value as |
@TerjeRusska Oh yes, sorry about that. We're slowly updating the provider to use quotes for every identifier (lots of benefits, including case sensitivity and not having unexpected plans), however we're far from done and haven't gotten round to updating this data source's output yet. |
Following Snowflakes' guidelines in Using Dynamic Data Masking
Current option to add
masking_policy
in snowflake_table (Resource) is not viable formasking_admin
role that has been grantedAPPLY MASKING POLICY
Provider for snowflake_table (Resource) to create/update the resource has
OWNERSHIP
privilege to the table. This is currently conflicting with themasking_admin
provider, that should only apply the masking policies. In some cases, table owner should not be able to set or unset masking policies.There's a need for separate resources that apply the following (and nothing else):
This will make sure that
masking_admin
can work without importing table resources owned by other roles.Also should add column information to snowflake_tables (Data Source) (or a new data source snowflake_columns?) to see what policies have already been applied.
The text was updated successfully, but these errors were encountered: