-
Notifications
You must be signed in to change notification settings - Fork 427
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: Connection resource #3162
Changes from 12 commits
c321654
6b989e3
fb8d018
6db06d8
24a2c80
5c8f84f
a5d59b6
f831c02
fa3db2b
e140406
fc4cd95
1dee95b
f0915c4
5291ab3
a6668d9
f8c64f7
68fce3d
661a8a4
993da0d
7197faa
fd52498
b739e99
d7b13de
147f85a
5394364
fb3d563
f9c4f6a
e665b38
44c1c05
215d6af
d0fb45c
ba98db7
9becdb9
ffe98a1
958a596
284e920
8ced116
dc08d74
ca44fcb
47edb32
9ed9076
4efce94
f86d26e
dcc24e0
e779da4
1263a91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,54 @@ across different versions. | |
|
||
## v0.97.0 ➞ v0.98.0 | ||
|
||
### *(new feature)* connection resource | ||
Added a new resource for managing connections. | ||
### *(new feature)* connection resources | ||
|
||
Added a new resources for managing connections. We decided to split connection into two separate resources based on whether the connection is primary or a replica (secondary). i.e.: | ||
|
||
- `snowflake_connection` is used as primary connection, with ability to enable failover to other accounts. | ||
- `snowflake_secondary_connection` is used as replica (secondary) connection. | ||
|
||
In order to promote secondary_connection to primary, resources need to be migrated (check [resource migration](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/resource_migration.md)) or re-created and imported using the following SQL statements on Snowflake Worksheet: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is good, but slightly rephrase that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this is fine to have this info in the migration guide, but eventually, it would be great to also include this in the resource docs (it's important information for later) |
||
|
||
``` | ||
CREATE CONNECTION <name> AS REPLICA OF <organization_name>.<account_name>.<connection_name>; | ||
ALTER CONNECTION <name> PRIMARY; | ||
``` | ||
|
||
See reference [docs](https://docs.snowflake.com/en/sql-reference/sql/create-connection). | ||
|
||
### snowflake_streams data source changes | ||
New filtering options: | ||
- `like` | ||
- `in` | ||
- `starts_with` | ||
- `limit` | ||
- `with_describe` | ||
|
||
New output fields | ||
- `show_output` | ||
- `describe_output` | ||
|
||
Breaking changes: | ||
- `database` and `schema` are right now under `in` field | ||
- `streams` field now organizes output of show under `show_output` field and the output of describe under `describe_output` field. | ||
|
||
Please adjust your Terraform configuration files. | ||
|
||
### *(behavior change)* Provider configuration rework | ||
On our road to v1, we have decided to rework configuration to address the most common issues (see a [roadmap entry](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#providers-configuration-rework)). We have created a list of topics we wanted to address before v1. We will prepare an announcement soon. The following subsections describe the things addressed in the v0.98.0. | ||
|
||
#### *(behavior change)* changed behavior of some fields | ||
For the fields that are not deprecated, we focused on improving validations and documentation. Also, we adjusted some fields to match our [driver's](https://github.com/snowflakedb/gosnowflake) defaults. Specifically: | ||
- Relaxed validations for enum fields like `protocol` and `authenticator`. Now, the case on such fields is ignored. | ||
- `user`, `warehouse`, `role` - added a validation for an account object identifier | ||
- `validate_default_parameters`, `client_request_mfa_token`, `client_store_temporary_credential`, `ocsp_fail_open`, - to easily handle three-value logic (true, false, unknown) in provider's config, type of these fields was changed from boolean to string. For more details about default values, please refer to the [changes before v1](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/CHANGES_BEFORE_V1.md#default-values) document. | ||
- `client_ip` - added a validation for an IP address | ||
- `port` - added a validation for a port number | ||
- `okta_url`, `token_accessor.token_endpoint`, `client_store_temporary_credential` - added a validation for a URL address | ||
- `login_timeout`, `request_timeout`, `jwt_expire_timeout`, `client_timeout`, `jwt_client_timeout`, `external_browser_timeout` - added a validation for setting this value to at least `0` | ||
- `authenticator` - added a possibility to configure JWT flow with `SNOWFLAKE_JWT` (formerly, this was upported with `JWT`); the previous value `JWT` was left for compatibility, but will be removed before v1 | ||
|
||
### *(behavior change)* handling copy_grants | ||
Currently, resources like `snowflake_view`, `snowflake_stream_on_table`, `snowflake_stream_on_external_table` and `snowflake_stream_on_directory_table` support `copy_grants` field corresponding with `COPY GRANTS` during `CREATE`. The current behavior is that, when a change leading for recreation is detected (meaning a change that can not be handled by ALTER, but only by `CREATE OR REPLACE`), `COPY GRANTS` are used during recreation when `copy_grants` is set to `true`. Changing this field without changes in other field results in a noop because in this case there is no need to recreate a resource. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
page_title: "snowflake_secondary_connection Resource - terraform-provider-snowflake" | ||
subcategory: "" | ||
description: |- | ||
Resource used to manage secondary connections. To promote secondary connection to primary check migraton guide https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#connection-resources. For more information, check connection documentation https://docs.snowflake.com/en/sql-reference/sql/create-connection.html. | ||
--- | ||
|
||
!> **V1 release candidate** This resource is a release candidate for the V1. It is on the list of remaining GA objects for V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the resource if needed. Any errors reported will be resolved with a higher priority. We encourage checking this resource out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0970--v0980) to use it. | ||
|
||
# snowflake_secondary_connection (Resource) | ||
|
||
Resource used to manage secondary connections. To promote secondary connection to primary check [migraton guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#connection-resources). For more information, check [connection documentation](https://docs.snowflake.com/en/sql-reference/sql/create-connection.html). | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
## Minimal | ||
resource "snowflake_secondary_connection" "basic" { | ||
name = "connection_name" | ||
as_replica_of = "<organization_name>.<account_name>.<connection_name>" | ||
} | ||
|
||
## Complete (with every optional set) | ||
resource "snowflake_secondary_connection" "complete" { | ||
name = "connection_name" | ||
as_replica_of = "<organization_name>.<account_name>.<connection_name>" | ||
comment = "my complete secondary connection" | ||
} | ||
``` | ||
-> **Note** Instead of using fully_qualified_name, you can reference objects managed outside Terraform by constructing a correct ID, consult [identifiers guide](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/guides/identifiers#new-computed-fully-qualified-name-field-in-resources). | ||
<!-- TODO(SNOW-1634854): include an example showing both methods--> | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `as_replica_of` (String) Specifies the identifier for a primary connection from which to create a replica (i.e. a secondary connection). | ||
- `name` (String) String that specifies the identifier (i.e. name) for the connection. Must start with an alphabetic character and may only contain letters, decimal digits (0-9), and underscores (_). For a secondary connection, the name must match the name of its primary connection. Due to technical limitations (read more [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/docs/technical-documentation/identifiers_rework_design_decisions.md#known-limitations-and-identifier-recommendations)), avoid using the following characters: `|`, `.`, `(`, `)`, `"` | ||
|
||
### Optional | ||
|
||
- `comment` (String) Specifies a comment for the secondary connection. | ||
|
||
### Read-Only | ||
|
||
- `fully_qualified_name` (String) Fully qualified name of the resource. For more information, see [object name resolution](https://docs.snowflake.com/en/sql-reference/name-resolution). | ||
- `id` (String) The ID of this resource. | ||
- `is_primary` (Boolean) Indicates if the connection has been changed to primary. If change is detected, the secondary connection will be recreated. | ||
- `show_output` (List of Object) Outputs the result of `SHOW CONNECTIONS` for the given connection. (see [below for nested schema](#nestedatt--show_output)) | ||
|
||
<a id="nestedatt--show_output"></a> | ||
### Nested Schema for `show_output` | ||
|
||
Read-Only: | ||
|
||
- `account_locator` (String) | ||
- `account_name` (String) | ||
- `comment` (String) | ||
- `connection_url` (String) | ||
- `created_on` (String) | ||
- `failover_allowed_to_accounts` (List of String) | ||
- `is_primary` (Boolean) | ||
- `name` (String) | ||
- `organization_name` (String) | ||
- `primary` (String) | ||
- `region_group` (String) | ||
- `snowflake_region` (String) | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import snowflake_secondary_connection.example 'secondary_connection_name' | ||
``` |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import snowflake_primary_connection.example 'connection_name' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Minimal | ||
resource "snowflake_primary_connection" "basic" { | ||
name = "connection_name" | ||
} | ||
|
||
## Complete (with every optional set) | ||
resource "snowflake_primary_connection" "complete" { | ||
name = "connection_name" | ||
comment = "my complete connection" | ||
enable_failover_to_accounts = [ | ||
"<secondary_account_organization_name>.<secondary_account_name>" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import snowflake_secondary_connection.example 'secondary_connection_name' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Minimal | ||
resource "snowflake_secondary_connection" "basic" { | ||
name = "connection_name" | ||
as_replica_of = "<organization_name>.<account_name>.<connection_name>" | ||
} | ||
|
||
## Complete (with every optional set) | ||
resource "snowflake_secondary_connection" "complete" { | ||
name = "connection_name" | ||
as_replica_of = "<organization_name>.<account_name>.<connection_name>" | ||
comment = "my complete secondary connection" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: snowflake_primary_connection