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: add new account resource #1492

Merged
merged 4 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
70 changes: 70 additions & 0 deletions docs/resources/account.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
page_title: "snowflake_account Resource - terraform-provider-snowflake"
subcategory: ""
description: |-
The account resource allows you to create and manage Snowflake accounts.
---

# snowflake_account (Resource)

The account resource allows you to create and manage Snowflake accounts.

**WARNING** This resource cannot be destroyed!!! The only way to delete accounts is to go through [Snowflake Support](https://docs.snowflake.com/en/user-guide/organizations-manage-accounts.html#deleting-an-account)

**NOTE** ORGADMIN priviliges are required for this resource

## Example Usage

```terraform
provider "snowflake" {
role = "ORGADMIN"
alias = "orgadmin"
}

resource "snowflake_account" "ac1" {
provider = snowflake.orgadmin
name = "SNOWFLAKE_TEST_ACCOUNT"
admin_name = "John Doe"
admin_password = "Abcd1234!"
email = "[email protected]"
first_name = "John"
last_name = "Doe"
must_change_password = true
edition = "STANDARD"
comment = "Snowflake Test Account"
region = "AWS_US_WEST_2"
}
```

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

### Required

- `admin_name` (String) Login name of the initial administrative user of the account. A new user is created in the new account with this name and password and granted the ACCOUNTADMIN role in the account. A login name can be any string consisting of letters, numbers, and underscores. Login names are always case-insensitive.
- `edition` (String) [Snowflake Edition](https://docs.snowflake.com/en/user-guide/intro-editions.html) of the account. Valid values are: STANDARD | ENTERPRISE | BUSINESS_CRITICAL
- `email` (String) Email address of the initial administrative user of the account. This email address is used to send any notifications about the account.
- `name` (String) Specifies the identifier (i.e. name) for the account; must be unique within an organization, regardless of which Snowflake Region the account is in. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters except for underscores (_). Note that if the account name includes underscores, features that do not accept account names with underscores (e.g. Okta SSO or SCIM) can reference a version of the account name that substitutes hyphens (-) for the underscores.

### Optional

- `admin_password` (String, Sensitive) Password for the initial administrative user of the account. Optional if the `ADMIN_RSA_PUBLIC_KEY` parameter is specified. For more information about passwords in Snowflake, see [Snowflake-provided Password Policy](https://docs.snowflake.com/en/sql-reference/sql/create-account.html#:~:text=Snowflake%2Dprovided%20Password%20Policy).
- `admin_rsa_public_key` (String, Sensitive) Assigns a public key to the initial administrative user of the account in order to implement [key pair authentication](https://docs.snowflake.com/en/sql-reference/sql/create-account.html#:~:text=key%20pair%20authentication) for the user. Optional if the `ADMIN_PASSWORD` parameter is specified.
- `comment` (String) Specifies a comment for the account.
- `first_name` (String) First name of the initial administrative user of the account
- `last_name` (String) Last name of the initial administrative user of the account
- `must_change_password` (Boolean) Specifies whether the new user created to administer the account is forced to change their password upon first login into the account.
- `region` (String) ID of the Snowflake Region where the account is created. If no value is provided, Snowflake creates the account in the same Snowflake Region as the current account (i.e. the account in which the CREATE ACCOUNT statement is executed.)
- `region_group` (String) ID of the Snowflake Region where the account is created. If no value is provided, Snowflake creates the account in the same Snowflake Region as the current account (i.e. the account in which the CREATE ACCOUNT statement is executed.)

### Read-Only

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

## Import

Import is supported using the following syntax:

```shell
terraform import snowflake_account.account <account_locator>
```
24 changes: 12 additions & 12 deletions docs/resources/object_parameter.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,47 @@ resource "snowflake_database" "d" {
}

resource "snowflake_object_parameter" "o" {
key = "SUSPEND_TASK_AFTER_NUM_FAILURES"
value = "33"
key = "SUSPEND_TASK_AFTER_NUM_FAILURES"
value = "33"
object_type = "DATABASE"
object_identifier {
name = snowflake_database.d.name
}
}

resource "snowflake_schema" "s" {
name = "TEST_SCHEMA"
name = "TEST_SCHEMA"
database = snowflake_database.d.name
}

resource "snowflake_object_parameter" "o2" {
key = "USER_TASK_TIMEOUT_MS"
value = "500"
key = "USER_TASK_TIMEOUT_MS"
value = "500"
object_type = "SCHEMA"
object_identifier {
database = snowflake_database.d.name
name = snowflake_schema.s.name
name = snowflake_schema.s.name
}
}

resource "snowflake_table" "t" {
name = "TEST_TABLE"
name = "TEST_TABLE"
database = snowflake_database.d.name
schema = snowflake_schema.s.name
schema = snowflake_schema.s.name
column {
name = "id"
type = "NUMBER"
}
}

resource "snowflake_object_parameter" "o3" {
key = "DATA_RETENTION_TIME_IN_DAYS"
value = "89"
key = "DATA_RETENTION_TIME_IN_DAYS"
value = "89"
object_type = "TABLE"
object_identifier {
database = snowflake_database.d.name
schema = snowflake_schema.s.name
name = snowflake_table.t.name
schema = snowflake_schema.s.name
name = snowflake_table.t.name
}
}
```
Expand Down
10 changes: 5 additions & 5 deletions docs/resources/table_constraint.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resource "snowflake_table" "t" {
nullable = false
}

column {
column {
name = "col3"
type = "text"
nullable = false
Expand Down Expand Up @@ -90,11 +90,11 @@ resource "snowflake_table_constraint" "foreign_key" {
}

resource "snowflake_table_constraint" "unique" {
name="unique"
type="UNIQUE"
name = "unique"
type = "UNIQUE"
table_id = snowflake_table.t.id
columns = ["col3"]
comment = "hello unique"
columns = ["col3"]
comment = "hello unique"
}
```

Expand Down
18 changes: 18 additions & 0 deletions examples/resources/snowflake_account/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provider "snowflake" {
role = "ORGADMIN"
alias = "orgadmin"
}

resource "snowflake_account" "ac1" {
provider = snowflake.orgadmin
name = "SNOWFLAKE_TEST_ACCOUNT"
admin_name = "John Doe"
admin_password = "Abcd1234!"
email = "[email protected]"
first_name = "John"
last_name = "Doe"
must_change_password = true
edition = "STANDARD"
comment = "Snowflake Test Account"
region = "AWS_US_WEST_2"
}
24 changes: 12 additions & 12 deletions examples/resources/snowflake_object_parameter/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@ resource "snowflake_database" "d" {
}

resource "snowflake_object_parameter" "o" {
key = "SUSPEND_TASK_AFTER_NUM_FAILURES"
value = "33"
key = "SUSPEND_TASK_AFTER_NUM_FAILURES"
value = "33"
object_type = "DATABASE"
object_identifier {
name = snowflake_database.d.name
}
}

resource "snowflake_schema" "s" {
name = "TEST_SCHEMA"
name = "TEST_SCHEMA"
database = snowflake_database.d.name
}

resource "snowflake_object_parameter" "o2" {
key = "USER_TASK_TIMEOUT_MS"
value = "500"
key = "USER_TASK_TIMEOUT_MS"
value = "500"
object_type = "SCHEMA"
object_identifier {
database = snowflake_database.d.name
name = snowflake_schema.s.name
name = snowflake_schema.s.name
}
}

resource "snowflake_table" "t" {
name = "TEST_TABLE"
name = "TEST_TABLE"
database = snowflake_database.d.name
schema = snowflake_schema.s.name
schema = snowflake_schema.s.name
column {
name = "id"
type = "NUMBER"
}
}

resource "snowflake_object_parameter" "o3" {
key = "DATA_RETENTION_TIME_IN_DAYS"
value = "89"
key = "DATA_RETENTION_TIME_IN_DAYS"
value = "89"
object_type = "TABLE"
object_identifier {
database = snowflake_database.d.name
schema = snowflake_schema.s.name
name = snowflake_table.t.name
schema = snowflake_schema.s.name
name = snowflake_table.t.name
}
}
10 changes: 5 additions & 5 deletions examples/resources/snowflake_table_constraint/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ resource "snowflake_table" "t" {
nullable = false
}

column {
column {
name = "col3"
type = "text"
nullable = false
Expand Down Expand Up @@ -75,9 +75,9 @@ resource "snowflake_table_constraint" "foreign_key" {
}

resource "snowflake_table_constraint" "unique" {
name="unique"
type="UNIQUE"
name = "unique"
type = "UNIQUE"
table_id = snowflake_table.t.id
columns = ["col3"]
comment = "hello unique"
columns = ["col3"]
comment = "hello unique"
}
1 change: 1 addition & 0 deletions pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func GetGrantResources() resources.TerraformGrantResources {
func getResources() map[string]*schema.Resource {
// NOTE(): do not add grant resources here
others := map[string]*schema.Resource{
"snowflake_account": resources.Account(),
"snowflake_account_parameter": resources.AccountParameter(),
"snowflake_api_integration": resources.APIIntegration(),
"snowflake_database": resources.Database(),
Expand Down
Loading