From 0598656d1f53fd31f11fc979555f0dea00fa107b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Cie=C5=9Blak?= Date: Thu, 6 Jun 2024 14:40:40 +0200 Subject: [PATCH] chore: Adjust before 0.92.0 (#2857) Changes: - Remove the re-create plan reported in https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2851 for notification integration - Remove secondary and shared databases from release as they're not ready yet --- MIGRATION_GUIDE.md | 11 --- docs/resources/secondary_database.md | 98 ------------------- docs/resources/shared_database.md | 81 --------------- pkg/provider/provider.go | 2 - pkg/resources/notification_integration.go | 1 - .../secondary_database_acceptance_test.go | 6 ++ .../shared_database_acceptance_test.go | 6 ++ pkg/sdk/identifier_helpers.go | 2 +- 8 files changed, 13 insertions(+), 194 deletions(-) delete mode 100644 docs/resources/secondary_database.md delete mode 100644 docs/resources/shared_database.md diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index cc9ec137b2..0042e1300b 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -4,17 +4,6 @@ This document is meant to help you migrate your Terraform config to the new newe describe deprecations or breaking changes and help you to change your configuration to keep the same (or similar) behavior across different versions. -## v0.91.0 ➞ v0.92.0 -### snowflake_database new alternatives -As part of the [preparation for v1](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#preparing-essential-ga-objects-for-the-provider-v1), we split up the database resource into multiple ones: -- Standard database (in progress) -- Shared database - can be used as `snowflake_shared_database` (used to create databases from externally defined shares) -- Secondary database - can be used as `snowflake_secondary_database` (used to create replicas of databases from external sources) -From now on, please migrate and use the new database resources for their unique use cases. For more information, see the documentation for those resources on the [Terraform Registry](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs). - -The split was done (and will be done for several objects during the refactor) to simplify the resource on maintainability and usage level. -Its purpose was also to divide the resources by their specific purpose rather than cramping every use case of an object into one resource. - ## v0.89.0 ➞ v0.90.0 ### snowflake_table resource changes #### *(behavior change)* Validation to column type added diff --git a/docs/resources/secondary_database.md b/docs/resources/secondary_database.md deleted file mode 100644 index 63383d4755..0000000000 --- a/docs/resources/secondary_database.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -page_title: "snowflake_secondary_database Resource - terraform-provider-snowflake" -subcategory: "" -description: |- - A secondary database creates a replica of an existing primary database (i.e. a secondary database). For more information about database replication, see Introduction to database replication across multiple accounts https://docs.snowflake.com/en/user-guide/db-replication-intro. ---- - -# snowflake_secondary_database (Resource) - -A secondary database creates a replica of an existing primary database (i.e. a secondary database). For more information about database replication, see [Introduction to database replication across multiple accounts](https://docs.snowflake.com/en/user-guide/db-replication-intro). - -## Example Usage - -```terraform -# 1. Preparing primary database -resource "snowflake_database" "primary" { - provider = primary_account # notice the provider fields - name = "database_name" - replication_configuration { - accounts = ["."] - ignore_edition_check = true - } -} - -# 2. Creating secondary database -resource "snowflake_secondary_database" "test" { - provider = secondary_account - name = snowflake_database.primary.name # It's recommended to give a secondary database the same name as its primary database - as_replica_of = "..${snowflake_database.primary.name}" - is_transient = false - - data_retention_time_in_days { - value = 10 - } - - max_data_extension_time_in_days { - value = 20 - } - - external_volume = "external_volume_name" - catalog = "catalog_name" - replace_invalid_characters = false - default_ddl_collation = "en_US" - storage_serialization_policy = "OPTIMIZED" - log_level = "OFF" - trace_level = "OFF" - comment = "A secondary database" -} -``` - - -## Schema - -### Required - -- `as_replica_of` (String) A fully qualified path to a database to create a replica from. A fully qualified path follows the format of `""."".""`. -- `name` (String) Specifies the identifier for the database; must be unique for your account. As a best practice for [Database Replication and Failover](https://docs.snowflake.com/en/user-guide/db-replication-intro), it is recommended to give each secondary database the same name as its primary database. This practice supports referencing fully-qualified objects (i.e. '..') by other objects in the same database, such as querying a fully-qualified table name in a view. If a secondary database has a different name from the primary database, then these object references would break in the secondary database. - -### Optional - -- `catalog` (String) The database parameter that specifies the default catalog to use for Iceberg tables. -- `comment` (String) Specifies a comment for the database. -- `data_retention_time_in_days` (Block List, Max: 1) Specifies the number of days for which Time Travel actions (CLONE and UNDROP) can be performed on the database, as well as specifying the default Time Travel retention time for all schemas created in the database. For more details, see [Understanding & Using Time Travel](https://docs.snowflake.com/en/user-guide/data-time-travel). (see [below for nested schema](#nestedblock--data_retention_time_in_days)) -- `default_ddl_collation` (String) Specifies a default collation specification for all schemas and tables added to the database. It can be overridden on schema or table level. For more information, see [collation specification](https://docs.snowflake.com/en/sql-reference/collation#label-collation-specification). -- `external_volume` (String) The database parameter that specifies the default external volume to use for Iceberg tables. -- `is_transient` (Boolean) Specifies the database as transient. Transient databases do not have a Fail-safe period so they do not incur additional storage costs once they leave Time Travel; however, this means they are also not protected by Fail-safe in the event of a data loss. -- `log_level` (String) Specifies the severity level of messages that should be ingested and made available in the active event table. Valid options are: [TRACE DEBUG INFO WARN ERROR FATAL OFF]. Messages at the specified level (and at more severe levels) are ingested. For more information, see [LOG_LEVEL](https://docs.snowflake.com/en/sql-reference/parameters.html#label-log-level). -- `max_data_extension_time_in_days` (Block List, Max: 1) Object parameter that specifies the maximum number of days for which Snowflake can extend the data retention period for tables in the database to prevent streams on the tables from becoming stale. For a detailed description of this parameter, see [MAX_DATA_EXTENSION_TIME_IN_DAYS](https://docs.snowflake.com/en/sql-reference/parameters.html#label-max-data-extension-time-in-days). (see [below for nested schema](#nestedblock--max_data_extension_time_in_days)) -- `replace_invalid_characters` (Boolean) Specifies whether to replace invalid UTF-8 characters with the Unicode replacement character (�) in query results for an Iceberg table. You can only set this parameter for tables that use an external Iceberg catalog. -- `storage_serialization_policy` (String) Specifies the storage serialization policy for Iceberg tables that use Snowflake as the catalog. Valid options are: [COMPATIBLE OPTIMIZED]. COMPATIBLE: Snowflake performs encoding and compression of data files that ensures interoperability with third-party compute engines. OPTIMIZED: Snowflake performs encoding and compression of data files that ensures the best table performance within Snowflake. -- `trace_level` (String) Controls how trace events are ingested into the event table. Valid options are: [ALWAYS ON_EVENT OFF]. For information about levels, see [TRACE_LEVEL](https://docs.snowflake.com/en/sql-reference/parameters.html#label-trace-level). - -### Read-Only - -- `id` (String) The ID of this resource. - - -### Nested Schema for `data_retention_time_in_days` - -Required: - -- `value` (Number) - - - -### Nested Schema for `max_data_extension_time_in_days` - -Required: - -- `value` (Number) - -## Import - -Import is supported using the following syntax: - -```shell -terraform import snowflake_secondary_database.example 'secondary_database_name' -``` diff --git a/docs/resources/shared_database.md b/docs/resources/shared_database.md deleted file mode 100644 index 271a1b7e01..0000000000 --- a/docs/resources/shared_database.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -page_title: "snowflake_shared_database Resource - terraform-provider-snowflake" -subcategory: "" -description: |- - A shared database creates a database from a share provided by another Snowflake account. For more information about shares, see Introduction to Secure Data Sharing https://docs.snowflake.com/en/user-guide/data-sharing-intro. ---- - -# snowflake_shared_database (Resource) - -A shared database creates a database from a share provided by another Snowflake account. For more information about shares, see [Introduction to Secure Data Sharing](https://docs.snowflake.com/en/user-guide/data-sharing-intro). - -## Example Usage - -```terraform -# 1. Preparing database to share -resource "snowflake_share" "test" { - provider = primary_account # notice the provider fields - name = "share_name" - accounts = ["."] -} - -resource "snowflake_database" "test" { - provider = primary_account - name = "shared_database" -} - -resource "snowflake_grant_privileges_to_share" "test" { - provider = primary_account - to_share = snowflake_share.test.name - privileges = ["USAGE"] - on_database = snowflake_database.test.name -} - -# 2. Creating shared database -resource "snowflake_shared_database" "test" { - provider = secondary_account - depends_on = [snowflake_grant_privileges_to_share.test] - name = snowflake_database.test.name # shared database should have the same as the "imported" one - from_share = "..${snowflake_share.test.name}" - is_transient = false - external_volume = "external_volume_name" - catalog = "catalog_name" - replace_invalid_characters = false - default_ddl_collation = "en_US" - storage_serialization_policy = "OPTIMIZED" - log_level = "OFF" - trace_level = "OFF" - comment = "A shared database" -} -``` - - -## Schema - -### Required - -- `from_share` (String) A fully qualified path to a share from which the database will be created. A fully qualified path follows the format of `"".""`. -- `name` (String) Specifies the identifier for the database; must be unique for your account. - -### Optional - -- `catalog` (String) The database parameter that specifies the default catalog to use for Iceberg tables. -- `comment` (String) Specifies a comment for the database. -- `default_ddl_collation` (String) Specifies a default collation specification for all schemas and tables added to the database. It can be overridden on schema or table level. For more information, see [collation specification](https://docs.snowflake.com/en/sql-reference/collation#label-collation-specification). -- `external_volume` (String) The database parameter that specifies the default external volume to use for Iceberg tables. -- `log_level` (String) Specifies the severity level of messages that should be ingested and made available in the active event table. Valid options are: [TRACE DEBUG INFO WARN ERROR FATAL OFF]. Messages at the specified level (and at more severe levels) are ingested. For more information, see [LOG_LEVEL](https://docs.snowflake.com/en/sql-reference/parameters.html#label-log-level). -- `replace_invalid_characters` (Boolean) Specifies whether to replace invalid UTF-8 characters with the Unicode replacement character (�) in query results for an Iceberg table. You can only set this parameter for tables that use an external Iceberg catalog. -- `storage_serialization_policy` (String) Specifies the storage serialization policy for Iceberg tables that use Snowflake as the catalog. Valid options are: [COMPATIBLE OPTIMIZED]. COMPATIBLE: Snowflake performs encoding and compression of data files that ensures interoperability with third-party compute engines. OPTIMIZED: Snowflake performs encoding and compression of data files that ensures the best table performance within Snowflake. -- `trace_level` (String) Controls how trace events are ingested into the event table. Valid options are: [ALWAYS ON_EVENT OFF]. For information about levels, see [TRACE_LEVEL](https://docs.snowflake.com/en/sql-reference/parameters.html#label-trace-level). - -### Read-Only - -- `id` (String) The ID of this resource. - -## Import - -Import is supported using the following syntax: - -```shell -terraform import snowflake_shared_database.example 'shared_database_name' -``` diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 90c3b25a44..457f3e0b14 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -494,11 +494,9 @@ func getResources() map[string]*schema.Resource { "snowflake_saml_integration": resources.SAMLIntegration(), "snowflake_schema": resources.Schema(), "snowflake_scim_integration": resources.SCIMIntegration(), - "snowflake_secondary_database": resources.SecondaryDatabase(), "snowflake_sequence": resources.Sequence(), "snowflake_session_parameter": resources.SessionParameter(), "snowflake_share": resources.Share(), - "snowflake_shared_database": resources.SharedDatabase(), "snowflake_stage": resources.Stage(), "snowflake_storage_integration": resources.StorageIntegration(), "snowflake_stream": resources.Stream(), diff --git a/pkg/resources/notification_integration.go b/pkg/resources/notification_integration.go index dbe835a6ed..a8db893f6e 100644 --- a/pkg/resources/notification_integration.go +++ b/pkg/resources/notification_integration.go @@ -35,7 +35,6 @@ var notificationIntegrationSchema = map[string]*schema.Schema{ Default: "QUEUE", ValidateFunc: validation.StringInSlice([]string{"QUEUE"}, true), Description: "A type of integration", - ForceNew: true, Deprecated: "Will be removed - it is added automatically on the SDK level.", }, "direction": { diff --git a/pkg/resources/secondary_database_acceptance_test.go b/pkg/resources/secondary_database_acceptance_test.go index cf58d60348..4b2186eb8d 100644 --- a/pkg/resources/secondary_database_acceptance_test.go +++ b/pkg/resources/secondary_database_acceptance_test.go @@ -15,6 +15,8 @@ import ( ) func TestAcc_CreateSecondaryDatabase_minimal(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() comment := random.Comment() @@ -98,6 +100,8 @@ func TestAcc_CreateSecondaryDatabase_minimal(t *testing.T) { } func TestAcc_CreateSecondaryDatabase_complete(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() comment := random.Comment() @@ -298,6 +302,8 @@ func TestAcc_CreateSecondaryDatabase_complete(t *testing.T) { } func TestAcc_CreateSecondaryDatabase_DataRetentionTimeInDays(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() _, externalPrimaryId, primaryDatabaseCleanup := acc.SecondaryTestClient().Database.CreatePrimaryDatabase(t, []sdk.AccountIdentifier{ diff --git a/pkg/resources/shared_database_acceptance_test.go b/pkg/resources/shared_database_acceptance_test.go index 6c90d5560c..768adfaacb 100644 --- a/pkg/resources/shared_database_acceptance_test.go +++ b/pkg/resources/shared_database_acceptance_test.go @@ -16,6 +16,8 @@ import ( ) func TestAcc_CreateSharedDatabase_minimal(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() comment := random.Comment() @@ -85,6 +87,8 @@ func TestAcc_CreateSharedDatabase_minimal(t *testing.T) { } func TestAcc_CreateSharedDatabase_complete(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + id := acc.TestClient().Ids.RandomAccountObjectIdentifier() comment := random.Comment() externalShareId := createShareableDatabase(t) @@ -179,6 +183,8 @@ func TestAcc_CreateSharedDatabase_complete(t *testing.T) { } func TestAcc_CreateSharedDatabase_InvalidValues(t *testing.T) { + t.Skip("To be unskipped in the next database pr") + comment := random.Comment() configVariables := func( diff --git a/pkg/sdk/identifier_helpers.go b/pkg/sdk/identifier_helpers.go index 0aae547e01..dde7b86686 100644 --- a/pkg/sdk/identifier_helpers.go +++ b/pkg/sdk/identifier_helpers.go @@ -123,7 +123,7 @@ func NewAccountIdentifier(organizationName, accountName string) AccountIdentifie func NewAccountIdentifierFromAccountLocator(accountLocator string) AccountIdentifier { return AccountIdentifier{ - accountLocator: strings.Trim(accountLocator, `"`), + accountLocator: accountLocator, } }