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

chore: Fix docs and update the protected users list #3365

Merged
merged 6 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 5 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ across different versions.
> [!TIP]
> We highly recommend upgrading the versions one by one instead of bulk upgrades.

## 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. This resulted in invalid SQL used during altering accounts. It has been fixed in this version.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please link the issue and explain what was not working (was it incorrect type, right?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


## v1.0.1 ➞ v1.0.2

### Fixed migration of account resource
Expand Down
3 changes: 2 additions & 1 deletion docs/resources/tag_association.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/user_authentication_policy_attachment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/user_password_policy_attachment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/view.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion examples/resources/snowflake_tag_association/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 1 addition & 0 deletions pkg/resources/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
},
},
},
Expand Down
18 changes: 9 additions & 9 deletions pkg/resources/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xDD

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice copy paste before :D

}
}

Expand All @@ -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 {
Expand Down Expand Up @@ -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))
}
}
}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
}
}
}
Expand Down Expand Up @@ -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))
}
}

Expand All @@ -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))
}
}

Expand Down Expand Up @@ -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))
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/sdk/data_metric_function_references_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(")"),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/sdk/data_metric_function_references_dto_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions pkg/sdk/data_metric_function_references_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sdk/data_metric_function_references_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestDataMetricFunctionReferences_GetForEntity(t *testing.T) {
opts := &GetForEntityDataMetricFunctionReferenceOptions{
parameters: &dataMetricFunctionReferenceParameters{
arguments: &dataMetricFunctionReferenceFunctionArguments{
refEntityDomain: Pointer(DataMetricFuncionRefEntityDomainView),
refEntityDomain: Pointer(DataMetricFunctionRefEntityDomainView),
},
},
}
Expand All @@ -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),
},
},
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/sdk/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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{
Expand Down
2 changes: 0 additions & 2 deletions pkg/sdk/sweepers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ func nukeUsers(client *Client) func() error {
"JAN_CIESLAK_LEGACY",
"TERRAFORM_SVC_ACCOUNT",
"TEST_CI_SERVICE_USER",
"FILIP_BUDZYNSKI",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;_;

"FILIP_BUDZYNSKI_LEGACY",
}

return func() error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pkg/sdk/testint/views_gen_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand All @@ -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)
Expand Down
Loading
Loading