Skip to content
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

feat: tag based masking policy #1143

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
688ad5d
add resource to provider
berosen Jul 13, 2022
584f011
update tag test
berosen Jul 13, 2022
fb2489d
add methods to tag attachment
berosen Jul 13, 2022
e6805c6
update tests
berosen Jul 13, 2022
c1524c6
add resource for tag masking policy attachment
berosen Jul 13, 2022
5f96e7d
add acceptance tests for masking policy attachment
berosen Jul 13, 2022
1fca868
add tests for policy attachment
berosen Jul 18, 2022
8c0867e
fix spelling
berosen Jul 18, 2022
560a357
add example and generate docs
berosen Jul 18, 2022
9614d34
add note about availability in enterprise
berosen Jul 18, 2022
2038b83
remove commented out line
berosen Jul 18, 2022
dacfe71
Revert "update tag test"
berosen Jul 18, 2022
4861a4a
Merge branch 'main' into feature/tag-masking-policy
berosen Jul 18, 2022
6a39c24
Merge branch 'main' into feature/tag-masking-policy
berosen Jul 19, 2022
8ebc432
Merge branch 'main' into feature/tag-masking-policy
berosen Aug 1, 2022
3180c36
Merge branch 'main' into feature/tag-masking-policy
berosen Aug 8, 2022
d3827f6
feat: adding new tag attachment resource
sfc-gh-jalin Aug 12, 2022
7ddbd5e
fixing minor changes
sfc-gh-jalin Aug 15, 2022
3e178b4
Revising retry for read
sfc-gh-jalin Aug 16, 2022
0e47105
Adding example for tag attachment
sfc-gh-jalin Aug 16, 2022
92eb8a1
Running make docs
sfc-gh-jalin Aug 16, 2022
c04e45c
Fixing bugs
sfc-gh-jalin Aug 16, 2022
70219c9
Final commit for tag attachment
sfc-gh-jalin Aug 19, 2022
ea4e703
Running make docs
sfc-gh-jalin Aug 19, 2022
79847dd
Fixing read and list tag attachment
sfc-gh-jalin Aug 19, 2022
a27dcaf
feat: add tag_association
sfc-gh-swinkler Aug 23, 2022
99e526e
feat: add tag_association
sfc-gh-swinkler Aug 23, 2022
f78b32c
feat: add tag_association
sfc-gh-swinkler Aug 23, 2022
bcac47f
add deprecation message
sfc-gh-swinkler Aug 23, 2022
979bcd1
update tag docs
sfc-gh-swinkler Aug 23, 2022
2cac339
update tag docs
sfc-gh-swinkler Aug 23, 2022
53fe3a1
update docs
sfc-gh-swinkler Aug 23, 2022
d4a37ba
fix integraiton tests failing
sfc-gh-swinkler Aug 23, 2022
2a7d882
fix integraiton tests failing
sfc-gh-swinkler Aug 23, 2022
5822de4
Merge branch 'main' into tag-reference
sfc-gh-swinkler Aug 23, 2022
ea16666
fix integraiton tests failing
sfc-gh-swinkler Aug 23, 2022
c9e8e1e
Merge branch 'tag-reference' of https://github.com/Snowflake-Labs/ter…
sfc-gh-swinkler Aug 23, 2022
ebcb66c
fix int tests failing
sfc-gh-swinkler Aug 23, 2022
b47d852
fix int tests failing
sfc-gh-swinkler Aug 23, 2022
b844854
fix int tests failing
sfc-gh-swinkler Aug 23, 2022
bc93e85
update go deps
sfc-gh-swinkler Aug 23, 2022
d374b86
update go mod
sfc-gh-swinkler Aug 23, 2022
b66f2fa
update docs
sfc-gh-swinkler Aug 23, 2022
c57182f
update docs
sfc-gh-swinkler Aug 23, 2022
ed6eaa9
tfproviderlint workflow
sfc-gh-swinkler Aug 23, 2022
e257407
update go mod
sfc-gh-swinkler Aug 23, 2022
834aa32
update go mod
sfc-gh-swinkler Aug 23, 2022
27bd0f9
remove go-misc
sfc-gh-swinkler Aug 23, 2022
bbfb1e3
update go mod
sfc-gh-swinkler Aug 23, 2022
4cff2e5
update go mod
sfc-gh-swinkler Aug 23, 2022
7fa001e
update go mod
sfc-gh-swinkler Aug 23, 2022
c6da4f4
update makefile
sfc-gh-swinkler Aug 23, 2022
43250b5
update int tests
sfc-gh-swinkler Aug 23, 2022
e0cbb90
comment out tfproviderlint
sfc-gh-swinkler Aug 23, 2022
6fdfa0f
Merge branch 'Snowflake-Labs:main' into feature/tag-masking-policy
berosen Aug 24, 2022
fc9e2aa
resolve merge conflics and format
berosen Aug 24, 2022
827ad2b
refactor to use new tag_id
berosen Aug 24, 2022
82ccecf
remove comment
berosen Aug 24, 2022
28c4f0e
update masking policy attachment unit tests
berosen Aug 24, 2022
50144f2
fix acceptance test
berosen Aug 25, 2022
3bb6055
update documentation
berosen Aug 25, 2022
6d820c0
* go mod tidy
berosen Aug 25, 2022
cfeac47
* rename file
berosen Aug 25, 2022
9f316ae
rename files
berosen Aug 25, 2022
160a0d6
rename file
berosen Aug 25, 2022
823ebaa
fix tests
berosen Aug 25, 2022
b2c2120
update acceptance test
berosen Aug 25, 2022
270c18c
rename resource
berosen Aug 25, 2022
4c097ba
update acc tests with proper resource name
berosen Aug 25, 2022
73f88ef
rename docs and examples
berosen Aug 25, 2022
8a59a68
rename file
berosen Aug 25, 2022
7b4b142
fix naming convention
berosen Aug 25, 2022
f575180
update docs
berosen Aug 25, 2022
cfcf186
make docs
berosen Aug 25, 2022
9c6557d
make docs
berosen Aug 25, 2022
8713bdc
update naming
berosen Aug 26, 2022
32e493e
update naming
berosen Aug 26, 2022
227a37f
update integration test ci
berosen Aug 26, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
run: make lint-ci

- name: make test-acceptance integration
Expand All @@ -67,6 +68,7 @@ jobs:
SNOWFLAKE_PASSWORD: ${{ secrets.SNOWFLAKE_PASSWORD }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_ROLE: ${{ secrets.SNOWFLAKE_ROLE }}
SNOWFLAKE_WAREHOUSE: ${{ secrets.SNOWFLAKE_WAREHOUSE }}
SNOWFLAKE_ACCOUNT_SECOND: ${{ secrets.SNOWFLAKE_ACCOUNT_SECOND }}
SNOWFLAKE_ACCOUNT_THIRD: ${{ secrets.SNOWFLAKE_ACCOUNT_THIRD }}
run: make test-acceptance
Expand Down
81 changes: 81 additions & 0 deletions docs/resources/tag_masking_policy_association.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "snowflake_tag_masking_policy_association Resource - terraform-provider-snowflake"
subcategory: ""
description: |-

---

# snowflake_tag_masking_policy_association (Resource)



## Example Usage

```terraform
# Note: Currently this feature is only available to accounts that are Enterprise Edition (or higher)

resource "snowflake_database" "test" {
name = "TEST_DB1"
data_retention_time_in_days = 1
}

resource "snowflake_database" "test2" {
name = "TEST_DB2"
data_retention_time_in_days = 1
}


resource "snowflake_schema" "test2" {
database = snowflake_database.test2.name
name = "FOOBAR2"
data_retention_days = snowflake_database.test2.data_retention_time_in_days
}

resource "snowflake_schema" "test" {
database = snowflake_database.test.name
name = "FOOBAR"
data_retention_days = snowflake_database.test.data_retention_time_in_days
}

resource "snowflake_tag" "this" {
name = upper("test_tag")
database = snowflake_database.test2.name
schema = snowflake_schema.test2.name
}

resource "snowflake_masking_policy" "example_masking_policy" {
name = "EXAMPLE_MASKING_POLICY"
database = snowflake_database.test.name
schema = snowflake_schema.test.name
value_data_type = "string"
masking_expression = "case when current_role() in ('ACCOUNTADMIN') then val else sha2(val, 512) end"
return_data_type = "string"
}

resource "snowflake_tag_masking_policy_association" "name" {
tag_id = snowflake_tag.this.id
masking_policy_id = snowflake_masking_policy.example_masking_policy.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `masking_policy_id` (String) The the resource id of the masking policy
- `tag_id` (String) Specifies the identifier for the tag. Note: format must follow: "databaseName"."schemaName"."tagName" or "databaseName.schemaName.tagName" or "databaseName|schemaName.tagName" (snowflake_tag.tag.id)

### Read-Only

- `id` (String) The ID of this resource.

## Import

Import is supported using the following syntax:

```shell
# format is tag database name | tag schema name | tag name | masking policy database | masking policy schema | masking policy name
terraform import snowflake_tag_masking_policy_association.example 'tag_db|tag_schema|tag_name|mp_db|mp_schema|mp_name'
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# format is tag database name | tag schema name | tag name | masking policy database | masking policy schema | masking policy name
terraform import snowflake_tag_masking_policy_association.example 'tag_db|tag_schema|tag_name|mp_db|mp_schema|mp_name'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Note: Currently this feature is only available to accounts that are Enterprise Edition (or higher)

resource "snowflake_database" "test" {
name = "TEST_DB1"
data_retention_time_in_days = 1
}

resource "snowflake_database" "test2" {
name = "TEST_DB2"
data_retention_time_in_days = 1
}


resource "snowflake_schema" "test2" {
database = snowflake_database.test2.name
name = "FOOBAR2"
data_retention_days = snowflake_database.test2.data_retention_time_in_days
}

resource "snowflake_schema" "test" {
database = snowflake_database.test.name
name = "FOOBAR"
data_retention_days = snowflake_database.test.data_retention_time_in_days
}

resource "snowflake_tag" "this" {
name = upper("test_tag")
database = snowflake_database.test2.name
schema = snowflake_schema.test2.name
}

resource "snowflake_masking_policy" "example_masking_policy" {
name = "EXAMPLE_MASKING_POLICY"
database = snowflake_database.test.name
schema = snowflake_schema.test.name
value_data_type = "string"
masking_expression = "case when current_role() in ('ACCOUNTADMIN') then val else sha2(val, 512) end"
return_data_type = "string"
}

resource "snowflake_tag_masking_policy_association" "name" {
tag_id = snowflake_tag.this.id
masking_policy_id = snowflake_masking_policy.example_masking_policy.id
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ require (

exclude github.co/mattn/go-ieproxy v0.0.3

exclude github.co/mattn/go-ieproxy v0.0.2
exclude github.co/mattn/go-ieproxy v0.0.2
77 changes: 39 additions & 38 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,44 +194,45 @@ func GetGrantResources() resources.TerraformGrantResources {
func getResources() map[string]*schema.Resource {
// NOTE(): do not add grant resources here
others := map[string]*schema.Resource{
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
"snowflake_external_function": resources.ExternalFunction(),
"snowflake_file_format": resources.FileFormat(),
"snowflake_function": resources.Function(),
"snowflake_managed_account": resources.ManagedAccount(),
"snowflake_masking_policy": resources.MaskingPolicy(),
"snowflake_materialized_view": resources.MaterializedView(),
"snowflake_network_policy_attachment": resources.NetworkPolicyAttachment(),
"snowflake_network_policy": resources.NetworkPolicy(),
"snowflake_oauth_integration": resources.OAuthIntegration(),
"snowflake_external_oauth_integration": resources.ExternalOauthIntegration(),
"snowflake_pipe": resources.Pipe(),
"snowflake_procedure": resources.Procedure(),
"snowflake_resource_monitor": resources.ResourceMonitor(),
"snowflake_role": resources.Role(),
"snowflake_role_grants": resources.RoleGrants(),
"snowflake_role_ownership_grant": resources.RoleOwnershipGrant(),
"snowflake_row_access_policy": resources.RowAccessPolicy(),
"snowflake_saml_integration": resources.SAMLIntegration(),
"snowflake_schema": resources.Schema(),
"snowflake_scim_integration": resources.SCIMIntegration(),
"snowflake_sequence": resources.Sequence(),
"snowflake_share": resources.Share(),
"snowflake_stage": resources.Stage(),
"snowflake_storage_integration": resources.StorageIntegration(),
"snowflake_notification_integration": resources.NotificationIntegration(),
"snowflake_stream": resources.Stream(),
"snowflake_table": resources.Table(),
"snowflake_external_table": resources.ExternalTable(),
"snowflake_tag": resources.Tag(),
"snowflake_tag_association": resources.TagAssociation(),
"snowflake_task": resources.Task(),
"snowflake_user": resources.User(),
"snowflake_user_ownership_grant": resources.UserOwnershipGrant(),
"snowflake_user_public_keys": resources.UserPublicKeys(),
"snowflake_view": resources.View(),
"snowflake_warehouse": resources.Warehouse(),
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
"snowflake_external_function": resources.ExternalFunction(),
"snowflake_file_format": resources.FileFormat(),
"snowflake_function": resources.Function(),
"snowflake_managed_account": resources.ManagedAccount(),
"snowflake_masking_policy": resources.MaskingPolicy(),
"snowflake_materialized_view": resources.MaterializedView(),
"snowflake_network_policy_attachment": resources.NetworkPolicyAttachment(),
"snowflake_network_policy": resources.NetworkPolicy(),
"snowflake_oauth_integration": resources.OAuthIntegration(),
"snowflake_external_oauth_integration": resources.ExternalOauthIntegration(),
"snowflake_pipe": resources.Pipe(),
"snowflake_procedure": resources.Procedure(),
"snowflake_resource_monitor": resources.ResourceMonitor(),
"snowflake_role": resources.Role(),
"snowflake_role_grants": resources.RoleGrants(),
"snowflake_role_ownership_grant": resources.RoleOwnershipGrant(),
"snowflake_row_access_policy": resources.RowAccessPolicy(),
"snowflake_saml_integration": resources.SAMLIntegration(),
"snowflake_schema": resources.Schema(),
"snowflake_scim_integration": resources.SCIMIntegration(),
"snowflake_sequence": resources.Sequence(),
"snowflake_share": resources.Share(),
"snowflake_stage": resources.Stage(),
"snowflake_storage_integration": resources.StorageIntegration(),
"snowflake_notification_integration": resources.NotificationIntegration(),
"snowflake_stream": resources.Stream(),
"snowflake_table": resources.Table(),
"snowflake_external_table": resources.ExternalTable(),
"snowflake_tag": resources.Tag(),
"snowflake_tag_association": resources.TagAssociation(),
"snowflake_tag_masking_policy_association": resources.TagMaskingPolicyAssociation(),
"snowflake_task": resources.Task(),
"snowflake_user": resources.User(),
"snowflake_user_ownership_grant": resources.UserOwnershipGrant(),
"snowflake_user_public_keys": resources.UserPublicKeys(),
"snowflake_view": resources.View(),
"snowflake_warehouse": resources.Warehouse(),
}

return mergeSchemas(
Expand Down
Loading