Skip to content

Commit

Permalink
feat: add failover groups (#1302)
Browse files Browse the repository at this point in the history
* feat: add failover groups

* feat: add failover groups

* feat: add failover groups
  • Loading branch information
sfc-gh-swinkler authored Oct 27, 2022
1 parent cf6e54f commit 687742c
Show file tree
Hide file tree
Showing 7 changed files with 1,126 additions and 0 deletions.
103 changes: 103 additions & 0 deletions docs/resources/failover_group.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "snowflake_failover_group Resource - terraform-provider-snowflake"
subcategory: ""
description: |-
---

# snowflake_failover_group (Resource)



## Example Usage

```terraform
resource "snowflake_database" "db" {
name = "db1"
}
resource "snowflake_failover_group" "source_failover_group" {
name = "FG1"
object_types = ["WAREHOUSES","DATABASES", "INTEGRATIONS", "ROLES"]
allowed_accounts= ["<account1>", "<account2>"]
allowed_databases = [snowflake_database.db.name]
allowed_integration_types = ["SECURITY INTEGRATIONS"]
replication_schedule {
cron {
expression = "0 0 10-20 * TUE,THU"
time_zone = "UTC"
}
}
}
provider "snowflake" {
alias = "account2"
}
resource "snowflake_failover_group" "target_failover_group" {
provider = snowflake.account2
name = "FG1"
from_replica {
organization_name = "..."
source_account_name = "..."
name = snowflake_failover_group.fg.name
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `name` (String) Specifies the identifier for the failover group. The identifier must start with an alphabetic character and cannot contain spaces or special characters unless the identifier string is enclosed in double quotes (e.g. "My object"). Identifiers enclosed in double quotes are also case-sensitive.

### Optional

- `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_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.
- `object_types` (Set of String) Type(s) of objects for which you are enabling replication and failover from the source account to the target account. The following object types are supported: "ACCOUNT PARAMETERS", "DATABASES", "INTEGRATIONS", "NETWORK POLICIES", "RESOURCE MONITORS", "ROLES", "SHARES", "USERS", "WAREHOUSES"
- `replication_schedule` (Block List, Max: 1) Specifies the schedule for refreshing secondary failover groups. (see [below for nested schema](#nestedblock--replication_schedule))

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--from_replica"></a>
### Nested Schema for `from_replica`

Required:

- `name` (String) Identifier for the primary failover group in the source account.
- `organization_name` (String) Name of your Snowflake organization.
- `source_account_name` (String) Source account from which you are enabling replication and failover of the specified objects.


<a id="nestedblock--replication_schedule"></a>
### Nested Schema for `replication_schedule`

Optional:

- `cron` (Block List, Max: 1) Specifies the cron expression for the replication schedule. The cron expression must be in the following format: "minute hour day-of-month month day-of-week". The following values are supported: minute: 0-59 hour: 0-23 day-of-month: 1-31 month: 1-12 day-of-week: 0-6 (0 is Sunday) (see [below for nested schema](#nestedblock--replication_schedule--cron))
- `interval` (Number) Specifies the interval in minutes for the replication schedule. The interval must be greater than 0 and less than 1440 (24 hours).

<a id="nestedblock--replication_schedule--cron"></a>
### Nested Schema for `replication_schedule.cron`

Required:

- `expression` (String) Specifies the cron expression for the replication schedule. The cron expression must be in the following format: "minute hour day-of-month month day-of-week". The following values are supported: minute: 0-59 hour: 0-23 day-of-month: 1-31 month: 1-12 day-of-week: 0-6 (0 is Sunday)
- `time_zone` (String) Specifies the time zone for secondary group refresh.

## Import

Import is supported using the following syntax:

```shell
terraform import snowflake_failover_group.example 'fg1'
```
1 change: 1 addition & 0 deletions examples/resources/snowflake_failover_group/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import snowflake_failover_group.example 'fg1'
31 changes: 31 additions & 0 deletions examples/resources/snowflake_failover_group/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
resource "snowflake_database" "db" {
name = "db1"
}

resource "snowflake_failover_group" "source_failover_group" {
name = "FG1"
object_types = ["WAREHOUSES","DATABASES", "INTEGRATIONS", "ROLES"]
allowed_accounts= ["<account1>", "<account2>"]
allowed_databases = [snowflake_database.db.name]
allowed_integration_types = ["SECURITY INTEGRATIONS"]
replication_schedule {
cron {
expression = "0 0 10-20 * TUE,THU"
time_zone = "UTC"
}
}
}

provider "snowflake" {
alias = "account2"
}

resource "snowflake_failover_group" "target_failover_group" {
provider = snowflake.account2
name = "FG1"
from_replica {
organization_name = "..."
source_account_name = "..."
name = snowflake_failover_group.fg.name
}
}
1 change: 1 addition & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func getResources() map[string]*schema.Resource {
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
"snowflake_external_function": resources.ExternalFunction(),
"snowflake_failover_group": resources.FailoverGroup(),
"snowflake_file_format": resources.FileFormat(),
"snowflake_function": resources.Function(),
"snowflake_managed_account": resources.ManagedAccount(),
Expand Down
Loading

0 comments on commit 687742c

Please sign in to comment.