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

feat: Connection resource #3162

Merged
merged 46 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c321654
initial commit for connections sdk
sfc-gh-fbudzynski Oct 18, 2024
6b989e3
added show and drop
sfc-gh-fbudzynski Oct 21, 2024
fb8d018
connection assert generated
sfc-gh-fbudzynski Oct 21, 2024
6db06d8
assertions generated
sfc-gh-fbudzynski Oct 22, 2024
24a2c80
integration test
sfc-gh-fbudzynski Oct 23, 2024
5c8f84f
before self-review
sfc-gh-fbudzynski Oct 24, 2024
a5d59b6
integration tests
sfc-gh-fbudzynski Oct 24, 2024
f831c02
simplified disable connection failover struct
sfc-gh-fbudzynski Oct 24, 2024
fa3db2b
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 24, 2024
e140406
init resource for connections
sfc-gh-fbudzynski Oct 25, 2024
fc4cd95
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 25, 2024
1dee95b
adjusted to comments from review
sfc-gh-fbudzynski Oct 25, 2024
f0915c4
Merge branch 'connection-sdk' into connection-resource
sfc-gh-fbudzynski Oct 25, 2024
5291ab3
create for connection resource
sfc-gh-fbudzynski Oct 25, 2024
a6668d9
merge conflict with main resolved
sfc-gh-fbudzynski Oct 28, 2024
f8c64f7
linter adjustemnts
sfc-gh-fbudzynski Oct 28, 2024
68fce3d
pre-push adjustment
sfc-gh-fbudzynski Oct 28, 2024
661a8a4
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 28, 2024
993da0d
resource CRUD functions
sfc-gh-fbudzynski Oct 28, 2024
7197faa
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 28, 2024
fd52498
added drop with if exists and HasPrimaryIdentifier extended function
sfc-gh-fbudzynski Oct 28, 2024
b739e99
pre-push adjustments
sfc-gh-fbudzynski Oct 28, 2024
d7b13de
added skips for tests
sfc-gh-fbudzynski Oct 28, 2024
147f85a
acceptance tests for connection
sfc-gh-fbudzynski Oct 28, 2024
5394364
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 28, 2024
fb3d563
with exists to connection resource delete
sfc-gh-fbudzynski Oct 29, 2024
f9c4f6a
resolved comments
sfc-gh-fbudzynski Oct 29, 2024
e665b38
Merge branch 'connection-sdk' into connection-resource
sfc-gh-fbudzynski Oct 29, 2024
44c1c05
connection resource with docs and migration guide
sfc-gh-fbudzynski Oct 29, 2024
215d6af
pre-push adjustments
sfc-gh-fbudzynski Oct 29, 2024
d0fb45c
self review small changes
sfc-gh-fbudzynski Oct 29, 2024
ba98db7
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Oct 30, 2024
9becdb9
changed naming for Set and Unset for connection
sfc-gh-fbudzynski Oct 30, 2024
ffe98a1
before discussing whether to split resource
sfc-gh-fbudzynski Oct 30, 2024
958a596
rename unset and set to unsetConnection and setConnection
sfc-gh-fbudzynski Oct 30, 2024
284e920
rename unset and set in tests
sfc-gh-fbudzynski Oct 30, 2024
8ced116
seperate connection resource to primary and secondary
sfc-gh-fbudzynski Oct 31, 2024
dc08d74
linter adjustemnts
sfc-gh-fbudzynski Oct 31, 2024
ca44fcb
secondary connection custom diff
sfc-gh-fbudzynski Oct 31, 2024
47edb32
pre-push adjustments
sfc-gh-fbudzynski Oct 31, 2024
9ed9076
merge request resolved
sfc-gh-fbudzynski Oct 31, 2024
4efce94
changed naming of primary connection, and adjusted to comments in pr
sfc-gh-fbudzynski Nov 4, 2024
f86d26e
added docs
sfc-gh-fbudzynski Nov 4, 2024
dcc24e0
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Nov 5, 2024
e779da4
custom diff for secondary_connection
sfc-gh-fbudzynski Nov 5, 2024
1263a91
Merge branch 'main' of github.com:Snowflake-Labs/terraform-provider-s…
sfc-gh-fbudzynski Nov 5, 2024
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
714 changes: 267 additions & 447 deletions MIGRATION_GUIDE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
page_title: "snowflake_connection Resource - terraform-provider-snowflake"
page_title: "snowflake_primary_connection Resource - terraform-provider-snowflake"
subcategory: ""
description: |-
Resource used to manage primary (not replicated) connections. 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_connection (Resource)
# snowflake_primary_connection (Resource)

Resource used to manage primary (not replicated) connections. For more information, check [connection documentation](https://docs.snowflake.com/en/sql-reference/sql/create-connection.html).

## Example Usage

```terraform
## Minimal
resource "snowflake_connection" "basic" {
resource "snowflake_primary_connection" "basic" {
name = "connection_name"
}

## Complete (with every optional set)
resource "snowflake_connection" "complete" {
resource "snowflake_primary_connection" "complete" {
name = "connection_name"
comment = "my complete connection"
enable_failover_to_accounts = [
Expand All @@ -47,7 +47,7 @@ resource "snowflake_connection" "complete" {

- `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.
- `show_output` (List of Object) Outputs the result of `SHOW CONNECTIONS` for the given secret. (see [below for nested schema](#nestedatt--show_output))
- `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`
Expand All @@ -72,5 +72,5 @@ Read-Only:
Import is supported using the following syntax:

```shell
terraform import snowflake_connection.example 'connection_name'
terraform import snowflake_primary_connection.example 'connection_name'
```
9 changes: 5 additions & 4 deletions docs/resources/secondary_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@
page_title: "snowflake_secondary_connection Resource - terraform-provider-snowflake"
subcategory: ""
description: |-
Resource used to manage secondary connections. For more information, check connection documentation https://docs.snowflake.com/en/sql-reference/sql/create-connection.html.
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. For more information, check [connection documentation](https://docs.snowflake.com/en/sql-reference/sql/create-connection.html).
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"
name = "connection_name"
as_replica_of = "<organization_name>.<account_name>.<connection_name>"
}

## Complete (with every optional set)
Expand Down Expand Up @@ -46,7 +47,7 @@ resource "snowflake_secondary_connection" "complete" {
- `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 secret. (see [below for nested schema](#nestedatt--show_output))
- `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`
Expand Down
1 change: 0 additions & 1 deletion examples/resources/snowflake_connection/import.sh

This file was deleted.

1 change: 1 addition & 0 deletions examples/resources/snowflake_primary_connection/import.sh
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
@@ -1,10 +1,10 @@
## Minimal
resource "snowflake_connection" "basic" {
resource "snowflake_primary_connection" "basic" {
name = "connection_name"
}

## Complete (with every optional set)
resource "snowflake_connection" "complete" {
resource "snowflake_primary_connection" "complete" {
name = "connection_name"
comment = "my complete connection"
enable_failover_to_accounts = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Minimal
resource "snowflake_secondary_connection" "basic" {
name = "connection_name"
name = "connection_name"
as_replica_of = "<organization_name>.<account_name>.<connection_name>"
}

## Complete (with every optional set)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ var allResourceSchemaDefs = []ResourceSchemaDef{
schema: resources.StreamOnView().Schema,
},
{
name: "Connection",
schema: resources.Connection().Schema,
name: "PrimaryConnection",
schema: resources.PrimaryConnection().Schema,
},
{
name: "SecondaryConnection",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ import (
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
)

/*
func (c *ConnectionResourceAssert) HasAsReplicaOfIdentifier(expected sdk.ExternalObjectIdentifier) *ConnectionResourceAssert {
expectedString := strings.ReplaceAll(expected.FullyQualifiedName(), `"`, "")
c.AddAssertion(assert.ValueSet("as_replica_of", expectedString))
return c
}
*/

func (c *ConnectionResourceAssert) HasEnableFailoverToAccounts(expected ...sdk.AccountIdentifier) *ConnectionResourceAssert {
func (c *PrimaryConnectionResourceAssert) HasExactlyFailoverToAccountsInOrder(expected ...sdk.AccountIdentifier) *PrimaryConnectionResourceAssert {
c.AddAssertion(assert.ValueSet("enable_failover_to_accounts.#", fmt.Sprintf("%d", len(expected))))
for i, v := range expected {
c.AddAssertion(assert.ValueSet(fmt.Sprintf("enable_failover_to_accounts.%d", i), v.Name()))
}
return c
}

func (c *ConnectionResourceAssert) HasNoEnableFailoverToAccounts() *ConnectionResourceAssert {
func (c *PrimaryConnectionResourceAssert) HasNoEnableFailoverToAccounts() *PrimaryConnectionResourceAssert {
c.AddAssertion(assert.ValueSet("enable_failover_to_accounts.#", "0"))
return c
}

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

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

func (c *ConnectionShowOutputAssert) HasPrimaryIdentifier(expected sdk.ExternalObjectIdentifier) *ConnectionShowOutputAssert {
// expectedString := strings.ReplaceAll(expected.FullyQualifiedName(), `"`, "")
c.AddAssertion(assert.ResourceShowOutputValueSet("primary", expected.Name()))
c.AddAssertion(assert.ResourceShowOutputValueSet("primary", expected.FullyQualifiedName()))
return c
}

Expand Down
Loading
Loading