Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
512 stars 402 forks source link

Masking policy with multiline statement updated every time #1097

Open kamilamarcinekpgs opened 2 years ago

kamilamarcinekpgs commented 2 years ago

Provider Version

0.36

Describe the bug

When masking policy is created using multiline string, like this:

  masking_expression = <<EOF
        case 
            when current_role() in ('ROLE_A') then 
                val 
            when is_role_in_session( 'ROLE_B' ) then 
                'ABC123'
            else
                '******'
        end
    EOF

then it is updated each time. The plan claim that it needs to replace case with the whole expression

Expected behavior

Plan should be empty when no change in masking expression is made.

image

jaloren commented 1 year ago

It looks like when the masking policy is stored in snowflake, it will truncate newlines on the last line of text. If you wrap the multi-line string in a chomp, then terraform shows no difference.