-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Masking policy resource v1 (#3078)
<!-- Feel free to delete comments as you fill this in --> - SDK - improve validations - add tests - improve options parsing (also, get rid of a 3rd party library) - add a TODO to reuse parsing from row access policies after merging #3079 - resource - use new id handling - rename/remove some fields to be consistent with other resources - better ACC tests - misc - adjust helper clients - generate config and assertion builders - adjust docs <!-- summary of changes --> ## Test Plan <!-- detail ways in which this PR has been tested or needs to be tested --> * [x] acceptance tests * [x] integration tests * [x] unit tests ## References <!-- issues documentation links, etc --> https://docs.snowflake.com/en/sql-reference/sql/create-masking-policy ## TODO - add tests for issues - rework data source
- Loading branch information
1 parent
8b1ece0
commit baa3a3c
Showing
48 changed files
with
2,204 additions
and
456 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
# format is database name | schema name | policy name | ||
terraform import snowflake_masking_policy.example 'dbName|schemaName|policyName' | ||
terraform import snowflake_row_access_policy.example '"<database_name>"."<schema_name>"."<masking_policy_name>"' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,61 @@ | ||
# basic resource | ||
resource "snowflake_masking_policy" "test" { | ||
name = "EXAMPLE_MASKING_POLICY" | ||
database = "EXAMPLE_DB" | ||
schema = "EXAMPLE_SCHEMA" | ||
signature { | ||
column { | ||
name = "val" | ||
type = "VARCHAR" | ||
} | ||
argument { | ||
name = "ARG1" | ||
type = "VARCHAR" | ||
} | ||
masking_expression = <<-EOF | ||
case | ||
when current_role() in ('ROLE_A') then | ||
val | ||
when is_role_in_session( 'ROLE_B' ) then | ||
'ABC123' | ||
else | ||
'******' | ||
end | ||
EOF | ||
|
||
argument { | ||
name = "ARG2" | ||
type = "NUMBER" | ||
} | ||
argument { | ||
name = "ARG3" | ||
type = "TIMESTAMP_NTZ" | ||
} | ||
body = <<-EOF | ||
case | ||
when current_role() in ('ROLE_A') then | ||
ARG1 | ||
when is_role_in_session( 'ROLE_B' ) then | ||
'ABC123' | ||
else | ||
'******' | ||
end | ||
EOF | ||
return_data_type = "VARCHAR" | ||
} | ||
|
||
# resource with all fields set | ||
resource "snowflake_masking_policy" "test" { | ||
name = "EXAMPLE_MASKING_POLICY" | ||
database = "EXAMPLE_DB" | ||
schema = "EXAMPLE_SCHEMA" | ||
argument { | ||
name = "ARG1" | ||
type = "VARCHAR" | ||
} | ||
argument { | ||
name = "ARG2" | ||
type = "NUMBER" | ||
} | ||
argument { | ||
name = "ARG3" | ||
type = "TIMESTAMP_NTZ" | ||
} | ||
body = <<-EOF | ||
case | ||
when current_role() in ('ROLE_A') then | ||
ARG1 | ||
when is_role_in_session( 'ROLE_B' ) then | ||
'ABC123' | ||
else | ||
'******' | ||
end | ||
EOF | ||
return_data_type = "VARCHAR" | ||
exempt_other_policies = "true" | ||
comment = "example masking policy" | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.