From f23e8cbcc5326ca60bb8f759c6970ecf4b0d64d6 Mon Sep 17 00:00:00 2001 From: Jakub Michalak Date: Tue, 4 Feb 2025 10:26:17 +0100 Subject: [PATCH] chore: Fix docs and update the protected users list (#3365) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add missing migration guide entry after #3343. - Adjust a tag association example. - Adjust and add missing notes about required warehouses. - Fix a few typos. - Remove @sfc-gh-fbudzynski from the list of protected users in sweepers because he is not a contributor. ## Test Plan * [ ] acceptance tests * [ ] … ## References --- MIGRATION_GUIDE.md | 3 ++ docs/resources/tag_association.md | 3 +- .../user_authentication_policy_attachment.md | 2 + .../user_password_policy_attachment.md | 2 + docs/resources/view.md | 2 +- .../snowflake_tag_association/resource.tf | 3 +- .../data_metric_function_references_client.go | 2 +- pkg/resources/table.go | 1 + pkg/resources/view.go | 18 ++++----- .../data_metric_function_references_def.go | 6 +-- ...ic_function_references_dto_builders_gen.go | 2 +- ...data_metric_function_references_dto_gen.go | 4 +- .../data_metric_function_references_gen.go | 4 +- ...ata_metric_function_references_gen_test.go | 4 +- pkg/sdk/parameters_test.go | 5 ++- pkg/sdk/sweepers_test.go | 2 - ...unction_references_gen_integration_test.go | 4 +- pkg/sdk/testint/views_gen_integration_test.go | 6 +-- ...r_authentication_policy_attachment.md.tmpl | 38 +++++++++++++++++++ .../user_password_policy_attachment.md.tmpl | 38 +++++++++++++++++++ templates/resources/view.md.tmpl | 2 +- 21 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 templates/resources/user_authentication_policy_attachment.md.tmpl create mode 100644 templates/resources/user_password_policy_attachment.md.tmpl diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index c6d7ac92c0..58d4fc6292 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -9,6 +9,9 @@ across different versions. ## v1.0.2 ➞ v1.0.3 +### Fixed ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES parameter +ENFORCE_NETWORK_RULES_FOR_INTERNAL_STAGES account parameter did not work correctly before ([#3344]). This parameter was of incorrect type, and the constructed queries did not provide the parameter's value during altering accounts. It has been fixed in this version. + ### Changed documentation structure We added `Preview` and `Stable` categories to the resources and data sources documentation, which clearly separates the preview and stable features in the documentation feature list. We moved our technical guides to `guides` directory. This means that all such guides are available natively in the registry, similarly to [Unassigning policies](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/unassigning_policies) guide. diff --git a/docs/resources/tag_association.md b/docs/resources/tag_association.md index f159c97119..d1e222f3d6 100644 --- a/docs/resources/tag_association.md +++ b/docs/resources/tag_association.md @@ -64,7 +64,8 @@ resource "snowflake_tag_association" "table_association" { } resource "snowflake_tag_association" "column_association" { - object_identifiers = [snowflake_database.test.fully_qualified_name] + # For now, column fully qualified names have to be constructed manually. + object_identifiers = [format("%s.\"column1\"", snowflake_table.test.fully_qualified_name)] object_type = "COLUMN" tag_id = snowflake_tag.test.fully_qualified_name tag_value = "engineering" diff --git a/docs/resources/user_authentication_policy_attachment.md b/docs/resources/user_authentication_policy_attachment.md index 9f94a7e087..68264948d4 100644 --- a/docs/resources/user_authentication_policy_attachment.md +++ b/docs/resources/user_authentication_policy_attachment.md @@ -7,6 +7,8 @@ description: |- !> **Caution: Preview Feature** This feature is considered a preview feature in the provider, regardless of the state of the resource in Snowflake. We do not guarantee its stability. It will be reworked and marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add the relevant feature name to `preview_features_enabled field` in the [provider configuration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#schema). Please always refer to the [Getting Help](https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#getting-help) section in our Github repo to best determine how to get help for your questions. +~> **Required warehouse** For this resource, the provider now uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) to get information about policies attached to users. This function requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. + # snowflake_user_authentication_policy_attachment (Resource) Specifies the authentication policy to use for a certain user. diff --git a/docs/resources/user_password_policy_attachment.md b/docs/resources/user_password_policy_attachment.md index 8f63d91d7e..1cb780483c 100644 --- a/docs/resources/user_password_policy_attachment.md +++ b/docs/resources/user_password_policy_attachment.md @@ -7,6 +7,8 @@ description: |- !> **Caution: Preview Feature** This feature is considered a preview feature in the provider, regardless of the state of the resource in Snowflake. We do not guarantee its stability. It will be reworked and marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add the relevant feature name to `preview_features_enabled field` in the [provider configuration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#schema). Please always refer to the [Getting Help](https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#getting-help) section in our Github repo to best determine how to get help for your questions. +~> **Required warehouse** For this resource, the provider now uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) to get information about policies attached to users. This function requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. + # snowflake_user_password_policy_attachment (Resource) Specifies the password policy to use for a certain user. diff --git a/docs/resources/view.md b/docs/resources/view.md index 7f6b92e658..1621cac497 100644 --- a/docs/resources/view.md +++ b/docs/resources/view.md @@ -9,7 +9,7 @@ description: |- ~> **Note about copy_grants** Fields like `is_recursive`, `is_temporary`, `copy_grants` and `statement` can not be ALTERed on Snowflake side (check [docs](https://docs.snowflake.com/en/sql-reference/sql/alter-view)), and a change on these fields means recreation of the resource. ForceNew can not be used because it does not preserve grants from `copy_grants`. Beware that even though a change is marked as update, the resource is recreated. -~> **Required warehouse** For this resource, the provider uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) which requires a warehouse in the connection. Please, make sure you have either set a DEFAULT_WAREHOUSE for the user, or specified a warehouse in the provider configuration. +~> **Required warehouse** For this resource, the provider uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) and [data metric function references](https://docs.snowflake.com/en/sql-reference/functions/data_metric_function_references) which requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. # snowflake_view (Resource) diff --git a/examples/resources/snowflake_tag_association/resource.tf b/examples/resources/snowflake_tag_association/resource.tf index 00a3cc1324..3dbd9055aa 100644 --- a/examples/resources/snowflake_tag_association/resource.tf +++ b/examples/resources/snowflake_tag_association/resource.tf @@ -44,7 +44,8 @@ resource "snowflake_tag_association" "table_association" { } resource "snowflake_tag_association" "column_association" { - object_identifiers = [snowflake_database.test.fully_qualified_name] + # For now, column fully qualified names have to be constructed manually. + object_identifiers = [format("%s.\"column1\"", snowflake_table.test.fully_qualified_name)] object_type = "COLUMN" tag_id = snowflake_tag.test.fully_qualified_name tag_value = "engineering" diff --git a/pkg/acceptance/helpers/data_metric_function_references_client.go b/pkg/acceptance/helpers/data_metric_function_references_client.go index 66914c4a0a..3fbb4da26e 100644 --- a/pkg/acceptance/helpers/data_metric_function_references_client.go +++ b/pkg/acceptance/helpers/data_metric_function_references_client.go @@ -19,7 +19,7 @@ func NewDataMetricFunctionReferencesClient(context *TestClientContext) *DataMetr } // GetDataMetricFunctionReferences is based on https://docs.snowflake.com/en/sql-reference/functions/data_metric_function_references. -func (c *DataMetricFunctionReferencesClient) GetDataMetricFunctionReferences(t *testing.T, id sdk.SchemaObjectIdentifier, domain sdk.DataMetricFuncionRefEntityDomainOption) []sdk.DataMetricFunctionReference { +func (c *DataMetricFunctionReferencesClient) GetDataMetricFunctionReferences(t *testing.T, id sdk.SchemaObjectIdentifier, domain sdk.DataMetricFunctionRefEntityDomainOption) []sdk.DataMetricFunctionReference { t.Helper() ctx := context.Background() diff --git a/pkg/resources/table.go b/pkg/resources/table.go index 3eb8bbe823..1c8280c402 100644 --- a/pkg/resources/table.go +++ b/pkg/resources/table.go @@ -153,6 +153,7 @@ var tableSchema = map[string]*schema.Schema{ Computed: true, Description: "Record of schema evolution.", }, + // TODO(SNOW-1348114): Consider adding fully_qualified_name for columns. Update the examples of referencing columns from other resources. }, }, }, diff --git a/pkg/resources/view.go b/pkg/resources/view.go index 71717adf96..91c08719b5 100644 --- a/pkg/resources/view.go +++ b/pkg/resources/view.go @@ -452,7 +452,7 @@ func CreateView(orReplace bool) schema.CreateContextFunc { } err := client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithSetDataMetricSchedule(*req)) if err != nil { - return diag.FromErr(fmt.Errorf("error setting data matric schedule in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error setting data metric schedule in view %v err = %w", id.Name(), err)) } } @@ -470,7 +470,7 @@ func CreateView(orReplace bool) schema.CreateContextFunc { } err = client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithAddDataMetricFunction(*sdk.NewViewAddDataMetricFunctionRequest(added))) if err != nil { - return diag.FromErr(fmt.Errorf("error adding data matric functions in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error adding data metric functions in view %v err = %w", id.Name(), err)) } changeSchedule := make([]sdk.ViewModifyDataMetricFunction, 0, len(addedRaw)) for i := range addedRaw { @@ -498,7 +498,7 @@ func CreateView(orReplace bool) schema.CreateContextFunc { if len(changeSchedule) > 0 { err = client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithModifyDataMetricFunction(*sdk.NewViewModifyDataMetricFunctionsRequest(changeSchedule))) if err != nil { - return diag.FromErr(fmt.Errorf("error adding data matric functions in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error adding data metric functions in view %v err = %w", id.Name(), err)) } } } @@ -724,7 +724,7 @@ func handlePolicyReferences(policyRefs []sdk.PolicyReference, d *schema.Resource } func handleDataMetricFunctions(ctx context.Context, client *sdk.Client, id sdk.SchemaObjectIdentifier, d *schema.ResourceData) error { - dataMetricFunctionReferences, err := client.DataMetricFunctionReferences.GetForEntity(ctx, sdk.NewGetForEntityDataMetricFunctionReferenceRequest(id, sdk.DataMetricFuncionRefEntityDomainView)) + dataMetricFunctionReferences, err := client.DataMetricFunctionReferences.GetForEntity(ctx, sdk.NewGetForEntityDataMetricFunctionReferenceRequest(id, sdk.DataMetricFunctionRefEntityDomainView)) if err != nil { return err } @@ -942,12 +942,12 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag } err := client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithSetDataMetricSchedule(*req)) if err != nil { - return diag.FromErr(fmt.Errorf("error setting data matric schedule in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error setting data metric schedule in view %v err = %w", id.Name(), err)) } } else { err := client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithUnsetDataMetricSchedule(*sdk.NewViewUnsetDataMetricScheduleRequest())) if err != nil { - return diag.FromErr(fmt.Errorf("error unsetting data matric schedule in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error unsetting data metric schedule in view %v err = %w", id.Name(), err)) } } } @@ -990,7 +990,7 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag } err := client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithDropDataMetricFunction(*sdk.NewViewDropDataMetricFunctionRequest(removed))) if err != nil { - return diag.FromErr(fmt.Errorf("error adding data matric functions in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error adding data metric functions in view %v err = %w", id.Name(), err)) } } @@ -1004,7 +1004,7 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag } err := client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithAddDataMetricFunction(*sdk.NewViewAddDataMetricFunctionRequest(added))) if err != nil { - return diag.FromErr(fmt.Errorf("error adding data matric functions in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error adding data metric functions in view %v err = %w", id.Name(), err)) } } @@ -1034,7 +1034,7 @@ func UpdateView(ctx context.Context, d *schema.ResourceData, meta any) diag.Diag } err = client.Views.Alter(ctx, sdk.NewAlterViewRequest(id).WithModifyDataMetricFunction(*sdk.NewViewModifyDataMetricFunctionsRequest(changeSchedule))) if err != nil { - return diag.FromErr(fmt.Errorf("error adding data matric functions in view %v err = %w", id.Name(), err)) + return diag.FromErr(fmt.Errorf("error adding data metric functions in view %v err = %w", id.Name(), err)) } } } diff --git a/pkg/sdk/data_metric_function_references_def.go b/pkg/sdk/data_metric_function_references_def.go index 1de2263ac6..f971e3b173 100644 --- a/pkg/sdk/data_metric_function_references_def.go +++ b/pkg/sdk/data_metric_function_references_def.go @@ -9,10 +9,10 @@ import ( //go:generate go run ./poc/main.go -type DataMetricFuncionRefEntityDomainOption string +type DataMetricFunctionRefEntityDomainOption string const ( - DataMetricFuncionRefEntityDomainView DataMetricFuncionRefEntityDomainOption = "VIEW" + DataMetricFunctionRefEntityDomainView DataMetricFunctionRefEntityDomainOption = "VIEW" ) type DataMetricScheduleStatusOption string @@ -100,7 +100,7 @@ var DataMetricFunctionReferenceDef = g.NewInterface( SQL(", "). Assignment( "REF_ENTITY_DOMAIN", - g.KindOfT[DataMetricFuncionRefEntityDomainOption](), + g.KindOfT[DataMetricFunctionRefEntityDomainOption](), g.ParameterOptions().SingleQuotes().ArrowEquals().Required(), ). SQL(")"), diff --git a/pkg/sdk/data_metric_function_references_dto_builders_gen.go b/pkg/sdk/data_metric_function_references_dto_builders_gen.go index a78dd8844a..6c18a074a4 100644 --- a/pkg/sdk/data_metric_function_references_dto_builders_gen.go +++ b/pkg/sdk/data_metric_function_references_dto_builders_gen.go @@ -6,7 +6,7 @@ import () func NewGetForEntityDataMetricFunctionReferenceRequest( refEntityName ObjectIdentifier, - RefEntityDomain DataMetricFuncionRefEntityDomainOption, + RefEntityDomain DataMetricFunctionRefEntityDomainOption, ) *GetForEntityDataMetricFunctionReferenceRequest { s := GetForEntityDataMetricFunctionReferenceRequest{} s.refEntityName = refEntityName diff --git a/pkg/sdk/data_metric_function_references_dto_gen.go b/pkg/sdk/data_metric_function_references_dto_gen.go index 68006a0545..b5760f5e0d 100644 --- a/pkg/sdk/data_metric_function_references_dto_gen.go +++ b/pkg/sdk/data_metric_function_references_dto_gen.go @@ -5,6 +5,6 @@ package sdk var _ optionsProvider[GetForEntityDataMetricFunctionReferenceOptions] = new(GetForEntityDataMetricFunctionReferenceRequest) type GetForEntityDataMetricFunctionReferenceRequest struct { - refEntityName ObjectIdentifier // required - RefEntityDomain DataMetricFuncionRefEntityDomainOption // required + refEntityName ObjectIdentifier // required + RefEntityDomain DataMetricFunctionRefEntityDomainOption // required } diff --git a/pkg/sdk/data_metric_function_references_gen.go b/pkg/sdk/data_metric_function_references_gen.go index 7170ae8f59..bcf79c1853 100644 --- a/pkg/sdk/data_metric_function_references_gen.go +++ b/pkg/sdk/data_metric_function_references_gen.go @@ -21,8 +21,8 @@ type dataMetricFunctionReferenceParameters struct { arguments *dataMetricFunctionReferenceFunctionArguments `ddl:"list,parentheses"` } type dataMetricFunctionReferenceFunctionArguments struct { - refEntityName []ObjectIdentifier `ddl:"parameter,single_quotes,arrow_equals" sql:"REF_ENTITY_NAME"` - refEntityDomain *DataMetricFuncionRefEntityDomainOption `ddl:"parameter,single_quotes,arrow_equals" sql:"REF_ENTITY_DOMAIN"` + refEntityName []ObjectIdentifier `ddl:"parameter,single_quotes,arrow_equals" sql:"REF_ENTITY_NAME"` + refEntityDomain *DataMetricFunctionRefEntityDomainOption `ddl:"parameter,single_quotes,arrow_equals" sql:"REF_ENTITY_DOMAIN"` } type dataMetricFunctionReferencesRow struct { diff --git a/pkg/sdk/data_metric_function_references_gen_test.go b/pkg/sdk/data_metric_function_references_gen_test.go index db7d737167..e6a0828b09 100644 --- a/pkg/sdk/data_metric_function_references_gen_test.go +++ b/pkg/sdk/data_metric_function_references_gen_test.go @@ -24,7 +24,7 @@ func TestDataMetricFunctionReferences_GetForEntity(t *testing.T) { opts := &GetForEntityDataMetricFunctionReferenceOptions{ parameters: &dataMetricFunctionReferenceParameters{ arguments: &dataMetricFunctionReferenceFunctionArguments{ - refEntityDomain: Pointer(DataMetricFuncionRefEntityDomainView), + refEntityDomain: Pointer(DataMetricFunctionRefEntityDomainView), }, }, } @@ -47,7 +47,7 @@ func TestDataMetricFunctionReferences_GetForEntity(t *testing.T) { parameters: &dataMetricFunctionReferenceParameters{ arguments: &dataMetricFunctionReferenceFunctionArguments{ refEntityName: []ObjectIdentifier{NewSchemaObjectIdentifier("a", "b", "c")}, - refEntityDomain: Pointer(DataMetricFuncionRefEntityDomainView), + refEntityDomain: Pointer(DataMetricFunctionRefEntityDomainView), }, }, } diff --git a/pkg/sdk/parameters_test.go b/pkg/sdk/parameters_test.go index 50418a6bb9..a1e265489f 100644 --- a/pkg/sdk/parameters_test.go +++ b/pkg/sdk/parameters_test.go @@ -25,7 +25,7 @@ func TestSetObjectParameterOnObject(t *testing.T) { }) } -func TestUnSetObjectParameterNetworkPolicyOnAccount(t *testing.T) { +func TestUnsetObjectParameterNetworkPolicyOnAccount(t *testing.T) { opts := &AlterAccountOptions{ Unset: &AccountUnset{ Parameters: &AccountLevelParametersUnset{ @@ -40,7 +40,7 @@ func TestUnSetObjectParameterNetworkPolicyOnAccount(t *testing.T) { }) } -func TestUnSetObjectParameterNetworkPolicyOnUser(t *testing.T) { +func TestUnsetObjectParameterNetworkPolicyOnUser(t *testing.T) { opts := &AlterUserOptions{ name: NewAccountObjectIdentifierFromFullyQualifiedName("TEST_USER"), Unset: &UserUnset{ @@ -54,6 +54,7 @@ func TestUnSetObjectParameterNetworkPolicyOnUser(t *testing.T) { }) } +// Proves https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3344 is fixed. func TestSetAccountParameterEnforceNetworkRulesForInternalStages(t *testing.T) { opts := &AlterAccountOptions{ Set: &AccountSet{ diff --git a/pkg/sdk/sweepers_test.go b/pkg/sdk/sweepers_test.go index 5fab04330e..aa19b7ad80 100644 --- a/pkg/sdk/sweepers_test.go +++ b/pkg/sdk/sweepers_test.go @@ -233,8 +233,6 @@ func nukeUsers(client *Client) func() error { "JAN_CIESLAK_LEGACY", "TERRAFORM_SVC_ACCOUNT", "TEST_CI_SERVICE_USER", - "FILIP_BUDZYNSKI", - "FILIP_BUDZYNSKI_LEGACY", } return func() error { diff --git a/pkg/sdk/testint/data_metric_function_references_gen_integration_test.go b/pkg/sdk/testint/data_metric_function_references_gen_integration_test.go index cf10780f10..5667572e84 100644 --- a/pkg/sdk/testint/data_metric_function_references_gen_integration_test.go +++ b/pkg/sdk/testint/data_metric_function_references_gen_integration_test.go @@ -29,11 +29,11 @@ func TestInt_DataMetricFunctionReferences(t *testing.T) { }}))) require.NoError(t, err) - dmfs, err := client.DataMetricFunctionReferences.GetForEntity(ctx, sdk.NewGetForEntityDataMetricFunctionReferenceRequest(view.ID(), sdk.DataMetricFuncionRefEntityDomainView)) + dmfs, err := client.DataMetricFunctionReferences.GetForEntity(ctx, sdk.NewGetForEntityDataMetricFunctionReferenceRequest(view.ID(), sdk.DataMetricFunctionRefEntityDomainView)) require.NoError(t, err) require.Equal(t, 1, len(dmfs)) dmf := dmfs[0] - assert.Equal(t, string(sdk.DataMetricFuncionRefEntityDomainView), strings.ToUpper(dmf.RefEntityDomain)) + assert.Equal(t, string(sdk.DataMetricFunctionRefEntityDomainView), strings.ToUpper(dmf.RefEntityDomain)) assert.Equal(t, functionId.DatabaseName(), dmf.MetricDatabaseName) assert.Equal(t, functionId.SchemaName(), dmf.MetricSchemaName) assert.Equal(t, functionId.Name(), dmf.MetricName) diff --git a/pkg/sdk/testint/views_gen_integration_test.go b/pkg/sdk/testint/views_gen_integration_test.go index df8db37ab8..dd49d6d8a8 100644 --- a/pkg/sdk/testint/views_gen_integration_test.go +++ b/pkg/sdk/testint/views_gen_integration_test.go @@ -513,7 +513,7 @@ func TestInt_Views(t *testing.T) { err = client.Views.Alter(ctx, alterRequest) require.NoError(t, err) - dataMetricFunctionReferences := testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFuncionRefEntityDomainView) + dataMetricFunctionReferences := testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFunctionRefEntityDomainView) require.Len(t, dataMetricFunctionReferences, 1) assertDataMetricFunctionReference(t, dataMetricFunctionReferences[0], view.ID(), cron) @@ -528,7 +528,7 @@ func TestInt_Views(t *testing.T) { err = client.Views.Alter(ctx, alterRequest) require.NoError(t, err) - dataMetricFunctionReferences = testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFuncionRefEntityDomainView) + dataMetricFunctionReferences = testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFunctionRefEntityDomainView) require.NoError(t, err) require.Len(t, dataMetricFunctionReferences, 0) @@ -546,7 +546,7 @@ func TestInt_Views(t *testing.T) { err = client.Views.Alter(ctx, alterRequest) require.NoError(t, err) - dataMetricFunctionReferences = testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFuncionRefEntityDomainView) + dataMetricFunctionReferences = testClientHelper().DataMetricFunctionReferences.GetDataMetricFunctionReferences(t, view.ID(), sdk.DataMetricFunctionRefEntityDomainView) require.Len(t, dataMetricFunctionReferences, 2) assertDataMetricFunctionReference(t, dataMetricFunctionReferences[0], view.ID(), cron) diff --git a/templates/resources/user_authentication_policy_attachment.md.tmpl b/templates/resources/user_authentication_policy_attachment.md.tmpl new file mode 100644 index 0000000000..16c0d26155 --- /dev/null +++ b/templates/resources/user_authentication_policy_attachment.md.tmpl @@ -0,0 +1,38 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "Preview" +description: |- +{{ if gt (len (split .Description "")) 1 -}} +{{ index (split .Description "") 1 | plainmarkdown | trimspace | prefixlines " " }} +{{- else -}} +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +{{- end }} +--- + +!> **Caution: Preview Feature** This feature is considered a preview feature in the provider, regardless of the state of the resource in Snowflake. We do not guarantee its stability. It will be reworked and marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add the relevant feature name to `preview_features_enabled field` in the [provider configuration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#schema). Please always refer to the [Getting Help](https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#getting-help) section in our Github repo to best determine how to get help for your questions. + +~> **Required warehouse** For this resource, the provider now uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) to get information about policies attached to users. This function requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile .ExampleFile }} + +-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](../guides/identifiers_rework_design_decisions#new-computed-fully-qualified-name-field-in-resources). + + +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" (printf "examples/resources/%s/import.sh" .Name)}} +{{- end }} diff --git a/templates/resources/user_password_policy_attachment.md.tmpl b/templates/resources/user_password_policy_attachment.md.tmpl new file mode 100644 index 0000000000..16c0d26155 --- /dev/null +++ b/templates/resources/user_password_policy_attachment.md.tmpl @@ -0,0 +1,38 @@ +--- +page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}" +subcategory: "Preview" +description: |- +{{ if gt (len (split .Description "")) 1 -}} +{{ index (split .Description "") 1 | plainmarkdown | trimspace | prefixlines " " }} +{{- else -}} +{{ .Description | plainmarkdown | trimspace | prefixlines " " }} +{{- end }} +--- + +!> **Caution: Preview Feature** This feature is considered a preview feature in the provider, regardless of the state of the resource in Snowflake. We do not guarantee its stability. It will be reworked and marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add the relevant feature name to `preview_features_enabled field` in the [provider configuration](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs#schema). Please always refer to the [Getting Help](https://github.com/Snowflake-Labs/terraform-provider-snowflake?tab=readme-ov-file#getting-help) section in our Github repo to best determine how to get help for your questions. + +~> **Required warehouse** For this resource, the provider now uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) to get information about policies attached to users. This function requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. + +# {{.Name}} ({{.Type}}) + +{{ .Description | trimspace }} + +{{ if .HasExample -}} +## Example Usage + +{{ tffile .ExampleFile }} + +-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](../guides/identifiers_rework_design_decisions#new-computed-fully-qualified-name-field-in-resources). + + +{{- end }} + +{{ .SchemaMarkdown | trimspace }} +{{- if .HasImport }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" (printf "examples/resources/%s/import.sh" .Name)}} +{{- end }} diff --git a/templates/resources/view.md.tmpl b/templates/resources/view.md.tmpl index d878d3e3c5..4a6c539efc 100644 --- a/templates/resources/view.md.tmpl +++ b/templates/resources/view.md.tmpl @@ -13,7 +13,7 @@ description: |- ~> **Note about copy_grants** Fields like `is_recursive`, `is_temporary`, `copy_grants` and `statement` can not be ALTERed on Snowflake side (check [docs](https://docs.snowflake.com/en/sql-reference/sql/alter-view)), and a change on these fields means recreation of the resource. ForceNew can not be used because it does not preserve grants from `copy_grants`. Beware that even though a change is marked as update, the resource is recreated. -~> **Required warehouse** For this resource, the provider uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) which requires a warehouse in the connection. Please, make sure you have either set a DEFAULT_WAREHOUSE for the user, or specified a warehouse in the provider configuration. +~> **Required warehouse** For this resource, the provider uses [policy references](https://docs.snowflake.com/en/sql-reference/functions/policy_references) and [data metric function references](https://docs.snowflake.com/en/sql-reference/functions/data_metric_function_references) which requires a warehouse in the connection. Please, make sure you have either set a `DEFAULT_WAREHOUSE` for the user, or specified a warehouse in the provider configuration. # {{.Name}} ({{.Type}})