Skip to content

Commit

Permalink
Resolve merge conflicts and adjust docs for databases
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jcieslak committed Jun 10, 2024
1 parent 7bc0613 commit ffd87e2
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 14 deletions.
10 changes: 9 additions & 1 deletion docs/resources/secondary_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ resource "snowflake_standard_database" "primary" {
}
# 2. Creating secondary database
## 2.1. Minimal version
resource "snowflake_secondary_database" "test" {
provider = secondary_account
name = snowflake_standard_database.primary.name # It's recommended to give a secondary database the same name as its primary database
as_replica_of = "<primary_account_organization_name>.<primary_account_name>.${snowflake_standard_database.primary.name}"
}
## 2.2. Complete version (with every optional set)
resource "snowflake_secondary_database" "test" {
provider = secondary_account
name = snowflake_standard_database.primary.name # It's recommended to give a secondary database the same name as its primary database
Expand All @@ -36,7 +44,7 @@ resource "snowflake_secondary_database" "test" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down
11 changes: 10 additions & 1 deletion docs/resources/shared_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ resource "snowflake_grant_privileges_to_share" "test" {
}
# 2. Creating shared database
## 2.1. Minimal version
resource "snowflake_shared_database" "test" {
provider = secondary_account
depends_on = [snowflake_grant_privileges_to_share.test]
name = snowflake_standard_database.test.name # shared database should have the same as the "imported" one
from_share = "<primary_account_organization_name>.<primary_account_name>.${snowflake_share.test.name}"
}
## 2.2. Complete version (with every optional set)
resource "snowflake_shared_database" "test" {
provider = secondary_account
depends_on = [snowflake_grant_privileges_to_share.test]
Expand All @@ -43,7 +52,7 @@ resource "snowflake_shared_database" "test" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down
14 changes: 10 additions & 4 deletions docs/resources/standard_database.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Represents a standard database. If replication configuration is specified, the d
## Example Usage

```terraform
## Minimal
resource "snowflake_standard_database" "primary" {
name = "database_name"
}
## Complete (with every optional set)
resource "snowflake_standard_database" "primary" {
name = "database_name"
is_transient = false
Expand All @@ -20,7 +26,7 @@ resource "snowflake_standard_database" "primary" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down Expand Up @@ -82,14 +88,14 @@ resource "snowflake_standard_database" "primary" {

Required:

- `enable_for_account` (Block List, Min: 1) Entry to enable replication and optionally failover for a given account identifier. (see [below for nested schema](#nestedblock--replication--enable_for_account))
- `enable_to_account` (Block List, Min: 1) Entry to enable replication and optionally failover for a given account identifier. (see [below for nested schema](#nestedblock--replication--enable_to_account))

Optional:

- `ignore_edition_check` (Boolean) Allows replicating data to accounts on lower editions in either of the following scenarios: 1. The primary database is in a Business Critical (or higher) account but one or more of the accounts approved for replication are on lower editions. Business Critical Edition is intended for Snowflake accounts with extremely sensitive data. 2. The primary database is in a Business Critical (or higher) account and a signed business associate agreement is in place to store PHI data in the account per HIPAA and HITRUST regulations, but no such agreement is in place for one or more of the accounts approved for replication, regardless if they are Business Critical (or higher) accounts. Both scenarios are prohibited by default in an effort to help prevent account administrators for Business Critical (or higher) accounts from inadvertently replicating sensitive data to accounts on lower editions.

<a id="nestedblock--replication--enable_for_account"></a>
### Nested Schema for `replication.enable_for_account`
<a id="nestedblock--replication--enable_to_account"></a>
### Nested Schema for `replication.enable_to_account`

Required:

Expand Down
10 changes: 9 additions & 1 deletion examples/resources/snowflake_secondary_database/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ resource "snowflake_standard_database" "primary" {
}

# 2. Creating secondary database
## 2.1. Minimal version
resource "snowflake_secondary_database" "test" {
provider = secondary_account
name = snowflake_standard_database.primary.name # It's recommended to give a secondary database the same name as its primary database
as_replica_of = "<primary_account_organization_name>.<primary_account_name>.${snowflake_standard_database.primary.name}"
}

## 2.2. Complete version (with every optional set)
resource "snowflake_secondary_database" "test" {
provider = secondary_account
name = snowflake_standard_database.primary.name # It's recommended to give a secondary database the same name as its primary database
Expand All @@ -22,7 +30,7 @@ resource "snowflake_secondary_database" "test" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down
11 changes: 10 additions & 1 deletion examples/resources/snowflake_shared_database/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ resource "snowflake_grant_privileges_to_share" "test" {
}

# 2. Creating shared database
## 2.1. Minimal version
resource "snowflake_shared_database" "test" {
provider = secondary_account
depends_on = [snowflake_grant_privileges_to_share.test]
name = snowflake_standard_database.test.name # shared database should have the same as the "imported" one
from_share = "<primary_account_organization_name>.<primary_account_name>.${snowflake_share.test.name}"
}

## 2.2. Complete version (with every optional set)
resource "snowflake_shared_database" "test" {
provider = secondary_account
depends_on = [snowflake_grant_privileges_to_share.test]
Expand All @@ -29,7 +38,7 @@ resource "snowflake_shared_database" "test" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down
8 changes: 7 additions & 1 deletion examples/resources/snowflake_standard_database/resource.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Minimal
resource "snowflake_standard_database" "primary" {
name = "database_name"
}

## Complete (with every optional set)
resource "snowflake_standard_database" "primary" {
name = "database_name"
is_transient = false
Expand All @@ -6,7 +12,7 @@ resource "snowflake_standard_database" "primary" {
data_retention_time_in_days = 10
max_data_extension_time_in_days = 20
external_volume = "<external_volume_name>"
catalog = "<external_volume_name>"
catalog = "<catalog_name>"
replace_invalid_characters = false
default_ddl_collation = "en_US"
storage_serialization_policy = "COMPATIBLE"
Expand Down
3 changes: 2 additions & 1 deletion pkg/helpers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package helpers

import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 3 additions & 1 deletion pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ func getResources() map[string]*schema.Resource {
"snowflake_alert": resources.Alert(),
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
"snowflake_standard_database": resources.StandardDatabase(),
"snowflake_database_role": resources.DatabaseRole(),
"snowflake_dynamic_table": resources.DynamicTable(),
"snowflake_email_notification_integration": resources.EmailNotificationIntegration(),
Expand Down Expand Up @@ -495,9 +494,12 @@ 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_standard_database": resources.StandardDatabase(),
"snowflake_stage": resources.Stage(),
"snowflake_storage_integration": resources.StorageIntegration(),
"snowflake_stream": resources.Stream(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "snowflake_shared_database" "test" {
name = var.name
from_share = var.from_share
comment = var.comment
name = var.name
from_share = var.from_share
comment = var.comment

external_volume = var.external_volume
catalog = var.catalog
Expand Down

0 comments on commit ffd87e2

Please sign in to comment.