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

fix: Update failover group allowed integration types #2776

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/resources/failover_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ resource "snowflake_failover_group" "target_failover_group" {

- `allowed_accounts` (Set of String) Specifies the target account or list of target accounts to which replication and failover of specified objects from the source account is enabled. Secondary failover groups in the target accounts in this list can be promoted to serve as the primary failover group in case of failover. Expected in the form <org_name>.<target_account_name>
- `allowed_databases` (Set of String) Specifies the database or list of databases for which you are enabling replication and failover from the source account to the target account. The OBJECT_TYPES list must include DATABASES to set this parameter.
- `allowed_integration_types` (Set of String) Type(s) of integrations for which you are enabling replication and failover from the source account to the target account. This property requires that the OBJECT_TYPES list include INTEGRATIONS to set this parameter. The following integration types are supported: "SECURITY INTEGRATIONS", "API INTEGRATIONS"
- `allowed_integration_types` (Set of String) Type(s) of integrations for which you are enabling replication and failover from the source account to the target account. This property requires that the OBJECT_TYPES list include INTEGRATIONS to set this parameter. The following integration types are supported: "SECURITY INTEGRATIONS", "API INTEGRATIONS", "STORAGE INTEGRATIONS", "EXTERNAL ACCESS INTEGRATIONS", "NOTIFICATION INTEGRATIONS"
- `allowed_shares` (Set of String) Specifies the share or list of shares for which you are enabling replication and failover from the source account to the target account. The OBJECT_TYPES list must include SHARES to set this parameter.
- `from_replica` (Block List, Max: 1) Specifies the name of the replica to use as the source for the failover group. (see [below for nested schema](#nestedblock--from_replica))
- `ignore_edition_check` (Boolean) Allows replicating objects to accounts on lower editions.
Expand Down
2 changes: 1 addition & 1 deletion pkg/resources/failover_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var failoverGroupSchema = map[string]*schema.Schema{
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
ConflictsWith: []string{"from_replica"},
Description: "Type(s) of integrations for which you are enabling replication and failover from the source account to the target account. This property requires that the OBJECT_TYPES list include INTEGRATIONS to set this parameter. The following integration types are supported: \"SECURITY INTEGRATIONS\", \"API INTEGRATIONS\"",
Description: "Type(s) of integrations for which you are enabling replication and failover from the source account to the target account. This property requires that the OBJECT_TYPES list include INTEGRATIONS to set this parameter. The following integration types are supported: \"SECURITY INTEGRATIONS\", \"API INTEGRATIONS\", \"STORAGE INTEGRATIONS\", \"EXTERNAL ACCESS INTEGRATIONS\", \"NOTIFICATION INTEGRATIONS\"",
},
"allowed_accounts": {
Type: schema.TypeSet,
Expand Down
8 changes: 6 additions & 2 deletions pkg/resources/failover_group_acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func TestAcc_FailoverGroupBasic(t *testing.T) {
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "object_types.#", "4"),
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "allowed_accounts.#", "1"),
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "allowed_databases.#", "1"),
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "allowed_integration_types.#", "1"),
resource.TestCheckTypeSetElemAttr("snowflake_failover_group.fg", "allowed_integration_types.*", "SECURITY INTEGRATIONS"),
resource.TestCheckTypeSetElemAttr("snowflake_failover_group.fg", "allowed_integration_types.*", "API INTEGRATIONS"),
resource.TestCheckTypeSetElemAttr("snowflake_failover_group.fg", "allowed_integration_types.*", "STORAGE INTEGRATIONS"),
resource.TestCheckTypeSetElemAttr("snowflake_failover_group.fg", "allowed_integration_types.*", "EXTERNAL ACCESS INTEGRATIONS"),
resource.TestCheckTypeSetElemAttr("snowflake_failover_group.fg", "allowed_integration_types.*", "NOTIFICATION INTEGRATIONS"),
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "replication_schedule.0.cron.0.expression", "0 0 10-20 * TUE,THU"),
resource.TestCheckResourceAttr("snowflake_failover_group.fg", "replication_schedule.0.cron.0.time_zone", "UTC"),
),
Expand Down Expand Up @@ -259,7 +263,7 @@ resource "snowflake_failover_group" "fg" {
object_types = ["WAREHOUSES", "DATABASES", "INTEGRATIONS", "ROLES"]
allowed_accounts= ["%s"]
allowed_databases = ["%s"]
allowed_integration_types = ["SECURITY INTEGRATIONS"]
allowed_integration_types = ["SECURITY INTEGRATIONS", "API INTEGRATIONS", "STORAGE INTEGRATIONS", "EXTERNAL ACCESS INTEGRATIONS", "NOTIFICATION INTEGRATIONS"]
replication_schedule {
cron {
expression = "0 0 10-20 * TUE,THU"
Expand Down
10 changes: 6 additions & 4 deletions pkg/sdk/failover_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ type failoverGroups struct {
type IntegrationType string

const (
IntegrationTypeSecurityIntegrations IntegrationType = "SECURITY INTEGRATIONS"
IntegrationTypeAPIIntegrations IntegrationType = "API INTEGRATIONS"
IntegrationTypeNotificationIntegrations IntegrationType = "NOTIFICATION INTEGRATIONS"
IntegrationTypeSecurityIntegrations IntegrationType = "SECURITY INTEGRATIONS"
IntegrationTypeAPIIntegrations IntegrationType = "API INTEGRATIONS"
IntegrationTypeStorageIntegrations IntegrationType = "STORAGE INTEGRATIONS"
IntegrationTypeExternalAccessIntegrations IntegrationType = "EXTERNAL ACCESS INTEGRATIONS"
IntegrationTypeNotificationIntegrations IntegrationType = "NOTIFICATION INTEGRATIONS"
)

// CreateFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-failover-group.
Expand Down Expand Up @@ -423,7 +425,7 @@ func (row failoverGroupDBRow) convert() *FailoverGroup {
if it == "" {
continue
}
allowedIntegrationTypes = append(allowedIntegrationTypes, IntegrationType(strings.TrimSpace(it)+" INTEGRATIONS"))
allowedIntegrationTypes = append(allowedIntegrationTypes, IntegrationType(strings.ReplaceAll(strings.TrimSpace(it), "_", " ")+" INTEGRATIONS"))
Copy link
Collaborator

Choose a reason for hiding this comment

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

bleh. But we will redo it with failover groups rework, fine for now

}
aas := strings.Split(row.AllowedAccounts, ",")
allowedAccounts := make([]AccountIdentifier, 0, len(aas))
Expand Down
4 changes: 4 additions & 0 deletions pkg/sdk/testint/failover_groups_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ func TestInt_FailoverGroupsCreate(t *testing.T) {
id := testClientHelper().Ids.RandomAccountObjectIdentifier()
objectTypes := []sdk.PluralObjectType{
sdk.PluralObjectTypeIntegrations,
sdk.PluralObjectTypeRoles,
}
allowedAccounts := []sdk.AccountIdentifier{
businessCriticalAccountId,
}
allowedIntegrationTypes := []sdk.IntegrationType{
sdk.IntegrationTypeSecurityIntegrations,
sdk.IntegrationTypeAPIIntegrations,
sdk.IntegrationTypeStorageIntegrations,
sdk.IntegrationTypeExternalAccessIntegrations,
sdk.IntegrationTypeNotificationIntegrations,
}
err := client.FailoverGroups.Create(ctx, id, objectTypes, allowedAccounts, &sdk.CreateFailoverGroupOptions{
Expand Down
Loading