diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 4881ccb5cc..3db0bdd5cb 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -17,50 +17,50 @@ import ( func Provider() *schema.Provider { return &schema.Provider{ Schema: map[string]*schema.Schema{ - "account": &schema.Schema{ + "account": { Type: schema.TypeString, Required: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_ACCOUNT", nil), }, - "username": &schema.Schema{ + "username": { Type: schema.TypeString, Required: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_USER", nil), }, - "password": &schema.Schema{ + "password": { Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_PASSWORD", nil), Sensitive: true, ConflictsWith: []string{"browser_auth", "private_key_path", "oauth_access_token"}, }, - "oauth_access_token": &schema.Schema{ + "oauth_access_token": { Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_OAUTH_ACCESS_TOKEN", nil), Sensitive: true, ConflictsWith: []string{"browser_auth", "private_key_path", "password"}, }, - "browser_auth": &schema.Schema{ + "browser_auth": { Type: schema.TypeBool, Optional: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_USE_BROWSER_AUTH", nil), Sensitive: false, ConflictsWith: []string{"password", "private_key_path", "oauth_access_token"}, }, - "private_key_path": &schema.Schema{ + "private_key_path": { Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_PRIVATE_KEY_PATH", nil), Sensitive: true, ConflictsWith: []string{"browser_auth", "password", "oauth_access_token"}, }, - "role": &schema.Schema{ + "role": { Type: schema.TypeString, Optional: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_ROLE", nil), }, - "region": &schema.Schema{ + "region": { Type: schema.TypeString, Required: true, DefaultFunc: schema.EnvDefaultFunc("SNOWFLAKE_REGION", "us-west-2"), diff --git a/pkg/resources/account_grant.go b/pkg/resources/account_grant.go index 09b83a1b8b..8a809129ed 100644 --- a/pkg/resources/account_grant.go +++ b/pkg/resources/account_grant.go @@ -20,7 +20,7 @@ var validAccountPrivileges = newPrivilegeSet( ) var accountGrantSchema = map[string]*schema.Schema{ - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the schema.", @@ -28,7 +28,7 @@ var accountGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validAccountPrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/database.go b/pkg/resources/database.go index e8d99b3f61..587897c6a6 100644 --- a/pkg/resources/database.go +++ b/pkg/resources/database.go @@ -12,29 +12,29 @@ import ( ) var databaseSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: false, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Default: "", }, - "data_retention_time_in_days": &schema.Schema{ + "data_retention_time_in_days": { Type: schema.TypeInt, Optional: true, Computed: true, }, - "from_share": &schema.Schema{ + "from_share": { Type: schema.TypeMap, Description: "Specify a provider and a share in this map to create a database from a share.", Optional: true, ForceNew: true, ConflictsWith: []string{"from_database"}, }, - "from_database": &schema.Schema{ + "from_database": { Type: schema.TypeString, Description: "Specify a database to create a clone from.", Optional: true, diff --git a/pkg/resources/database_grant.go b/pkg/resources/database_grant.go index 4cb8cabce3..202ed8736f 100644 --- a/pkg/resources/database_grant.go +++ b/pkg/resources/database_grant.go @@ -18,13 +18,13 @@ var ValidDatabasePrivileges = newPrivilegeSet( ) var databaseGrantSchema = map[string]*schema.Schema{ - "database_name": &schema.Schema{ + "database_name": { Type: schema.TypeString, Required: true, Description: "The name of the database on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the database.", @@ -32,14 +32,14 @@ var databaseGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(ValidDatabasePrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": &schema.Schema{ + "shares": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/integration_grant.go b/pkg/resources/integration_grant.go index 5591c072d5..a58feb231a 100644 --- a/pkg/resources/integration_grant.go +++ b/pkg/resources/integration_grant.go @@ -12,13 +12,13 @@ var validIntegrationPrivileges = newPrivilegeSet( privilegeOwnership, ) var integrationGrantSchema = map[string]*schema.Schema{ - "integration_name": &schema.Schema{ + "integration_name": { Type: schema.TypeString, Required: true, Description: "Identifier for the integration; must be unique for your account.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the integration.", @@ -26,7 +26,7 @@ var integrationGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validIntegrationPrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/managed_account.go b/pkg/resources/managed_account.go index 95e1fe12cd..6b9b46f98d 100644 --- a/pkg/resources/managed_account.go +++ b/pkg/resources/managed_account.go @@ -25,19 +25,19 @@ var managedAccountProperties = []string{ } var managedAccountSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Identifier for the managed account; must be unique for your account.", ForceNew: true, }, - "admin_name": &schema.Schema{ + "admin_name": { Type: schema.TypeString, Required: true, Description: "Identifier, as well as login name, for the initial user in the managed account. This user serves as the account administrator for the account.", ForceNew: true, }, - "admin_password": &schema.Schema{ + "admin_password": { Type: schema.TypeString, Required: true, Sensitive: true, @@ -45,7 +45,7 @@ var managedAccountSchema = map[string]*schema.Schema{ ValidateFunc: snowflakeValidation.ValidatePassword, ForceNew: true, }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Optional: true, Default: SnowflakeReaderAccountType, @@ -53,33 +53,33 @@ var managedAccountSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice([]string{SnowflakeReaderAccountType}, true), ForceNew: true, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the managed account.", ForceNew: true, }, - "cloud": &schema.Schema{ + "cloud": { Type: schema.TypeString, Computed: true, Description: "Cloud in which the managed account is located.", }, - "region": &schema.Schema{ + "region": { Type: schema.TypeString, Computed: true, Description: "Snowflake Region in which the managed account is located.", }, - "locator": &schema.Schema{ + "locator": { Type: schema.TypeString, Computed: true, Description: "Display name of the managed account.", }, - "created_on": &schema.Schema{ + "created_on": { Type: schema.TypeString, Computed: true, Description: "Date and time when the managed account was created.", }, - "url": &schema.Schema{ + "url": { Type: schema.TypeString, Computed: true, Description: "URL for accessing the managed account, particularly through the web interface.", diff --git a/pkg/resources/pipe.go b/pkg/resources/pipe.go index acf519d9e2..b8ac91a571 100644 --- a/pkg/resources/pipe.go +++ b/pkg/resources/pipe.go @@ -17,30 +17,30 @@ const ( ) var pipeSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, Description: "Specifies the identifier for the pipe; must be unique for the database and schema in which the pipe is created.", }, - "schema": &schema.Schema{ + "schema": { Type: schema.TypeString, Required: true, ForceNew: true, Description: "The schema in which to create the pipe.", }, - "database": &schema.Schema{ + "database": { Type: schema.TypeString, Required: true, ForceNew: true, Description: "The database in which to create the pipe.", }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the pipe.", }, - "copy_statement": &schema.Schema{ + "copy_statement": { Type: schema.TypeString, Required: true, ForceNew: true, @@ -52,19 +52,19 @@ var pipeSchema = map[string]*schema.Schema{ return false }, }, - "auto_ingest": &schema.Schema{ + "auto_ingest": { Type: schema.TypeBool, Optional: true, Default: false, ForceNew: true, Description: "Specifies a auto_ingest param for the pipe.", }, - "notification_channel": &schema.Schema{ + "notification_channel": { Type: schema.TypeString, Computed: true, Description: "Amazon Resource Name of the Amazon SQS queue for the stage named in the DEFINITION column.", }, - "owner": &schema.Schema{ + "owner": { Type: schema.TypeString, Computed: true, Description: "Name of the role that owns the pipe.", diff --git a/pkg/resources/resource_monitor.go b/pkg/resources/resource_monitor.go index 99fc77aa17..5e3b3cbddb 100644 --- a/pkg/resources/resource_monitor.go +++ b/pkg/resources/resource_monitor.go @@ -15,20 +15,20 @@ import ( var validFrequencies = []string{"MONTHLY", "DAILY", "WEEKLY", "YEARLY", "NEVER"} var resourceMonitorSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Identifier for the resource monitor; must be unique for your account.", ForceNew: true, }, - "credit_quota": &schema.Schema{ + "credit_quota": { Type: schema.TypeFloat, Optional: true, Computed: true, Description: "The amount of credits allocated monthly to the resource monitor, round up to 2 decimal places.", ForceNew: true, }, - "frequency": &schema.Schema{ + "frequency": { Type: schema.TypeString, Optional: true, Computed: true, @@ -36,34 +36,34 @@ var resourceMonitorSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validFrequencies, false), ForceNew: true, }, - "start_timestamp": &schema.Schema{ + "start_timestamp": { Type: schema.TypeString, Optional: true, Computed: true, Description: "The date and time when the resource monitor starts monitoring credit usage for the assigned warehouses.", ForceNew: true, }, - "end_timestamp": &schema.Schema{ + "end_timestamp": { Type: schema.TypeString, Optional: true, Description: "The date and time when the resource monitor suspends the assigned warehouses.", ForceNew: true, }, - "suspend_triggers": &schema.Schema{ + "suspend_triggers": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeInt}, Optional: true, Description: "A list of percentage thresholds at which to suspend all warehouses.", ForceNew: true, }, - "suspend_immediate_triggers": &schema.Schema{ + "suspend_immediate_triggers": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeInt}, Optional: true, Description: "A list of percentage thresholds at which to immediately suspend all warehouses.", ForceNew: true, }, - "notify_triggers": &schema.Schema{ + "notify_triggers": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeInt}, Optional: true, diff --git a/pkg/resources/resource_monitor_grant.go b/pkg/resources/resource_monitor_grant.go index d6fbf519cd..f244a63d33 100644 --- a/pkg/resources/resource_monitor_grant.go +++ b/pkg/resources/resource_monitor_grant.go @@ -13,13 +13,13 @@ var validResourceMonitorPrivileges = newPrivilegeSet( ) var resourceMonitorGrantSchema = map[string]*schema.Schema{ - "monitor_name": &schema.Schema{ + "monitor_name": { Type: schema.TypeString, Required: true, Description: "Identifier for the resource monitor; must be unique for your account.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the resource monitor.", @@ -27,7 +27,7 @@ var resourceMonitorGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validResourceMonitorPrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/role.go b/pkg/resources/role.go index 668776b3bd..14e17ac5f5 100644 --- a/pkg/resources/role.go +++ b/pkg/resources/role.go @@ -10,11 +10,11 @@ import ( var roleProperties = []string{"comment"} var roleSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, // TODO validation diff --git a/pkg/resources/role_grants.go b/pkg/resources/role_grants.go index 666e6056a0..8e96eb76c5 100644 --- a/pkg/resources/role_grants.go +++ b/pkg/resources/role_grants.go @@ -18,7 +18,7 @@ func RoleGrants() *schema.Resource { Update: UpdateRoleGrants, Schema: map[string]*schema.Schema{ - "role_name": &schema.Schema{ + "role_name": { Type: schema.TypeString, Elem: &schema.Schema{Type: schema.TypeString}, Required: true, @@ -27,13 +27,13 @@ func RoleGrants() *schema.Resource { return snowflake.ValidateIdentifier(val) }, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants role to this specified role.", }, - "users": &schema.Schema{ + "users": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/schema.go b/pkg/resources/schema.go index f5347cfb99..56e86c62a3 100644 --- a/pkg/resources/schema.go +++ b/pkg/resources/schema.go @@ -19,37 +19,37 @@ const ( ) var schemaSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Specifies the identifier for the schema; must be unique for the database in which the schema is created.", ForceNew: true, }, - "database": &schema.Schema{ + "database": { Type: schema.TypeString, Required: true, Description: "The database in which to create the schema.", ForceNew: true, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the schema.", }, - "is_transient": &schema.Schema{ + "is_transient": { Type: schema.TypeBool, Optional: true, Default: false, Description: "Specifies a schema as transient. Transient schemas do not have a Fail-safe period so they do not incur additional storage costs once they leave Time Travel; however, this means they are also not protected by Fail-safe in the event of a data loss.", ForceNew: true, }, - "is_managed": &schema.Schema{ + "is_managed": { Type: schema.TypeBool, Optional: true, Default: false, Description: "Specifies a managed schema. Managed access schemas centralize privilege management with the schema owner.", }, - "data_retention_days": &schema.Schema{ + "data_retention_days": { Type: schema.TypeInt, Optional: true, Default: 1, diff --git a/pkg/resources/schema_grant.go b/pkg/resources/schema_grant.go index ea6a9689ed..5a94412b99 100644 --- a/pkg/resources/schema_grant.go +++ b/pkg/resources/schema_grant.go @@ -32,19 +32,19 @@ var validSchemaPrivileges = newPrivilegeSet( ) var schemaGrantSchema = map[string]*schema.Schema{ - "schema_name": &schema.Schema{ + "schema_name": { Type: schema.TypeString, Optional: true, Description: "The name of the schema on which to grant privileges.", ForceNew: true, }, - "database_name": &schema.Schema{ + "database_name": { Type: schema.TypeString, Required: true, Description: "The name of the database containing the schema on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the current or future schema. Note that if \"OWNERSHIP\" is specified, ensure that the role that terraform is using is granted access.", @@ -52,21 +52,21 @@ var schemaGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validSchemaPrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": &schema.Schema{ + "shares": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these shares (only valid if on_future is unset).", ForceNew: true, }, - "on_future": &schema.Schema{ + "on_future": { Type: schema.TypeBool, Optional: true, Description: "When this is set to true, apply this grant on all future schemas in the given database. The schema_name and shares fields must be unset in order to use on_future.", diff --git a/pkg/resources/share.go b/pkg/resources/share.go index 614cdcd9d5..82733c3717 100644 --- a/pkg/resources/share.go +++ b/pkg/resources/share.go @@ -17,17 +17,17 @@ var shareProperties = []string{ } var shareSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Specifies the identifier for the share; must be unique for the account in which the share is created.", }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the managed account.", }, - "accounts": &schema.Schema{ + "accounts": { // Changed from Set to List to use DiffSuppressFunc: https://github.com/hashicorp/terraform-plugin-sdk/issues/160 Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, diff --git a/pkg/resources/stage.go b/pkg/resources/stage.go index 26d1136583..a51529edf8 100644 --- a/pkg/resources/stage.go +++ b/pkg/resources/stage.go @@ -17,56 +17,56 @@ const ( ) var stageSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Specifies the identifier for the stage; must be unique for the database and schema in which the stage is created.", ForceNew: true, }, - "database": &schema.Schema{ + "database": { Type: schema.TypeString, Required: true, Description: "The database in which to create the stage.", ForceNew: true, }, - "schema": &schema.Schema{ + "schema": { Type: schema.TypeString, Required: true, Description: "The schema in which to create the stage.", ForceNew: true, }, - "url": &schema.Schema{ + "url": { Type: schema.TypeString, Optional: true, Description: "Specifies the URL for the stage.", }, - "credentials": &schema.Schema{ + "credentials": { Type: schema.TypeString, Optional: true, Description: "Specifies the credentials for the stage.", Sensitive: true, }, - "storage_integration": &schema.Schema{ + "storage_integration": { Type: schema.TypeString, Optional: true, Description: "Specifies the name of the storage integration used to delegate authentication responsibility for external cloud storage to a Snowflake identity and access management (IAM) entity.", }, - "file_format": &schema.Schema{ + "file_format": { Type: schema.TypeString, Optional: true, Description: "Specifies the file format for the stage.", }, - "copy_options": &schema.Schema{ + "copy_options": { Type: schema.TypeString, Optional: true, Description: "Specifies the copy options for the stage.", }, - "encryption": &schema.Schema{ + "encryption": { Type: schema.TypeString, Optional: true, Description: "Specifies the encryption settings for the stage.", }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the stage.", diff --git a/pkg/resources/stage_grant.go b/pkg/resources/stage_grant.go index 6a3c03974e..72c1f907d5 100644 --- a/pkg/resources/stage_grant.go +++ b/pkg/resources/stage_grant.go @@ -17,25 +17,25 @@ var ValidStagePrivileges = newPrivilegeSet( ) var stageGrantSchema = map[string]*schema.Schema{ - "stage_name": &schema.Schema{ + "stage_name": { Type: schema.TypeString, Required: true, Description: "The name of the stage on which to grant privileges.", ForceNew: true, }, - "schema_name": &schema.Schema{ + "schema_name": { Type: schema.TypeString, Required: true, Description: "The name of the schema containing the current stage on which to grant privileges.", ForceNew: true, }, - "database_name": &schema.Schema{ + "database_name": { Type: schema.TypeString, Required: true, Description: "The name of the database containing the current stage on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the stage.", @@ -43,14 +43,14 @@ var stageGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(ValidStagePrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": &schema.Schema{ + "shares": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, diff --git a/pkg/resources/storage_integration.go b/pkg/resources/storage_integration.go index 8edaab19eb..287e01f364 100644 --- a/pkg/resources/storage_integration.go +++ b/pkg/resources/storage_integration.go @@ -13,66 +13,66 @@ import ( var storageIntegrationSchema = map[string]*schema.Schema{ // The first part of the schema is shared between all integration vendors - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, ForceNew: true, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Default: "", }, - "type": &schema.Schema{ + "type": { Type: schema.TypeString, Optional: true, Default: "EXTERNAL_STAGE", ValidateFunc: validation.StringInSlice([]string{"EXTERNAL_STAGE"}, true), }, - "enabled": &schema.Schema{ + "enabled": { Type: schema.TypeBool, Optional: true, Default: true, }, - "storage_allowed_locations": &schema.Schema{ + "storage_allowed_locations": { Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, Required: true, Description: "Explicitly limits external stages that use the integration to reference one or more storage locations.", }, - "storage_blocked_locations": &schema.Schema{ + "storage_blocked_locations": { Type: schema.TypeList, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Explicitly prohibits external stages that use the integration from referencing one or more storage locations.", }, // This part of the schema is the cloudProviderParams in the Snowflake documentation and differs between vendors - "storage_provider": &schema.Schema{ + "storage_provider": { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{"S3", "GCS", "AZURE"}, false), }, - "storage_aws_external_id": &schema.Schema{ + "storage_aws_external_id": { Type: schema.TypeString, Computed: true, Description: "The external ID that Snowflake will use when assuming the AWS role.", }, - "storage_aws_iam_user_arn": &schema.Schema{ + "storage_aws_iam_user_arn": { Type: schema.TypeString, Computed: true, Description: "The Snowflake user that will attempt to assume the AWS role.", }, - "storage_aws_role_arn": &schema.Schema{ + "storage_aws_role_arn": { Type: schema.TypeString, Optional: true, Default: "", }, - "azure_tenant_id": &schema.Schema{ + "azure_tenant_id": { Type: schema.TypeString, Optional: true, Default: "", }, - "created_on": &schema.Schema{ + "created_on": { Type: schema.TypeString, Computed: true, Description: "Date and time when the storage integration was created.", diff --git a/pkg/resources/table_grant.go b/pkg/resources/table_grant.go index 2004a71519..945c61dd3e 100644 --- a/pkg/resources/table_grant.go +++ b/pkg/resources/table_grant.go @@ -18,25 +18,25 @@ var validTablePrivileges = newPrivilegeSet( ) var tableGrantSchema = map[string]*schema.Schema{ - "table_name": &schema.Schema{ + "table_name": { Type: schema.TypeString, Optional: true, Description: "The name of the table on which to grant privileges immediately (only valid if on_future is unset).", ForceNew: true, }, - "schema_name": &schema.Schema{ + "schema_name": { Type: schema.TypeString, Optional: true, Description: "The name of the schema containing the current or future tables on which to grant privileges.", ForceNew: true, }, - "database_name": &schema.Schema{ + "database_name": { Type: schema.TypeString, Required: true, Description: "The name of the database containing the current or future tables on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the current or future table.", @@ -44,21 +44,21 @@ var tableGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validTablePrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": &schema.Schema{ + "shares": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these shares (only valid if on_future is unset).", ForceNew: true, }, - "on_future": &schema.Schema{ + "on_future": { Type: schema.TypeBool, Optional: true, Description: "When this is set to true and a schema_name is provided, apply this grant on all future tables in the given schema. When this is true and no schema_name is provided apply this grant on all future tables in the given database. The table_name and shares fields must be unset in order to use on_future.", diff --git a/pkg/resources/task.go b/pkg/resources/task.go index 2c48395838..483518dc8b 100644 --- a/pkg/resources/task.go +++ b/pkg/resources/task.go @@ -19,69 +19,69 @@ const ( ) var taskSchema = map[string]*schema.Schema{ - "enabled": &schema.Schema{ + "enabled": { Type: schema.TypeBool, Optional: true, Default: false, Description: "Specifies if the task should be started (enabled) after creation or should remain suspended (default).", }, - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Specifies the identifier for the task; must be unique for the database and schema in which the task is created.", ForceNew: true, }, - "database": &schema.Schema{ + "database": { Type: schema.TypeString, Required: true, Description: "The database in which to create the task.", ForceNew: true, }, - "schema": &schema.Schema{ + "schema": { Type: schema.TypeString, Required: true, Description: "The schema in which to create the task.", ForceNew: true, }, - "warehouse": &schema.Schema{ + "warehouse": { Type: schema.TypeString, Required: true, Description: "The warehouse the task will use.", ForceNew: false, }, - "schedule": &schema.Schema{ + "schedule": { Type: schema.TypeString, Optional: true, Description: "The schedule for periodically running the task. This can be a cron or interval in minutes.", }, - "session_parameters": &schema.Schema{ + "session_parameters": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Specifies session parameters to set for the session when the task runs. A task supports all session parameters.", }, - "user_task_timeout_ms": &schema.Schema{ + "user_task_timeout_ms": { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 86400000), Description: "Specifies the time limit on a single run of the task before it times out (in milliseconds).", }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the task.", }, - "after": &schema.Schema{ + "after": { Type: schema.TypeString, Optional: true, Description: "Specifies the predecessor task in the same database and schema of the current task. When a run of the predecessor task finishes successfully, it triggers this task (after a brief lag).", }, - "when": &schema.Schema{ + "when": { Type: schema.TypeString, Optional: true, Description: "Specifies a Boolean SQL expression; multiple conditions joined with AND/OR are supported.", }, - "sql_statement": &schema.Schema{ + "sql_statement": { Type: schema.TypeString, Required: true, Description: "Any single SQL statement, or a call to a stored procedure, executed when the task runs.", diff --git a/pkg/resources/user.go b/pkg/resources/user.go index 08339f3e4c..5e43264589 100644 --- a/pkg/resources/user.go +++ b/pkg/resources/user.go @@ -26,11 +26,11 @@ var diffCaseInsensitive = func(k, old, new string, d *schema.ResourceData) bool } var userSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Name of the user. Note that if you do not supply login_name this will be used as login_name. [doc](https://docs.snowflake.net/manuals/sql-reference/sql/create-user.html#required-parameters)"}, - "login_name": &schema.Schema{ + "login_name": { Type: schema.TypeString, Optional: true, Computed: true, @@ -38,56 +38,56 @@ var userSchema = map[string]*schema.Schema{ // login_name is case-insensitive DiffSuppressFunc: diffCaseInsensitive, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, // TODO validation }, - "password": &schema.Schema{ + "password": { Type: schema.TypeString, Optional: true, Sensitive: true, Description: "**WARNING:** this will put the password in the terraform state file. Use carefully.", // TODO validation https://docs.snowflake.net/manuals/sql-reference/sql/create-user.html#optional-parameters }, - "disabled": &schema.Schema{ + "disabled": { Type: schema.TypeBool, Optional: true, Computed: true, }, - "default_warehouse": &schema.Schema{ + "default_warehouse": { Type: schema.TypeString, Optional: true, Description: "Specifies the virtual warehouse that is active by default for the user’s session upon login.", }, - "default_namespace": &schema.Schema{ + "default_namespace": { Type: schema.TypeString, Optional: true, DiffSuppressFunc: diffCaseInsensitive, Description: "Specifies the namespace (database only or database and schema) that is active by default for the user’s session upon login.", }, - "default_role": &schema.Schema{ + "default_role": { Type: schema.TypeString, Optional: true, Computed: true, Description: "Specifies the role that is active by default for the user’s session upon login.", }, - "rsa_public_key": &schema.Schema{ + "rsa_public_key": { Type: schema.TypeString, Optional: true, Description: "Specifies the user’s RSA public key; used for key-pair authentication. Must be on 1 line without header and trailer.", }, - "rsa_public_key_2": &schema.Schema{ + "rsa_public_key_2": { Type: schema.TypeString, Optional: true, Description: "Specifies the user’s second RSA public key; used to rotate the public and private keys for key-pair authentication based on an expiration schedule set by your organization. Must be on 1 line without header and trailer.", }, - "has_rsa_public_key": &schema.Schema{ + "has_rsa_public_key": { Type: schema.TypeBool, Computed: true, Description: "Will be true if user as an RSA key set.", }, - "must_change_password": &schema.Schema{ + "must_change_password": { Type: schema.TypeBool, Optional: true, Description: "Specifies whether the user is forced to change their password on next login (including their first/initial login) into the system.", diff --git a/pkg/resources/view.go b/pkg/resources/view.go index 907d9d8e69..ff11eee8d0 100644 --- a/pkg/resources/view.go +++ b/pkg/resources/view.go @@ -15,42 +15,42 @@ import ( var space = regexp.MustCompile(`\s+`) var viewSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, Description: "Specifies the identifier for the view; must be unique for the schema in which the view is created. Don't use the | character.", }, - "database": &schema.Schema{ + "database": { Type: schema.TypeString, Required: true, Description: "The database in which to create the view. Don't use the | character.", ForceNew: true, }, - "schema": &schema.Schema{ + "schema": { Type: schema.TypeString, Optional: true, Default: "PUBLIC", Description: "The schema in which to create the view. Don't use the | character.", ForceNew: true, }, - "or_replace": &schema.Schema{ + "or_replace": { Type: schema.TypeBool, Optional: true, Default: false, Description: "Overwrites the View if it exists.", }, - "is_secure": &schema.Schema{ + "is_secure": { Type: schema.TypeBool, Optional: true, Default: false, Description: "Specifies that the view is secure.", }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Description: "Specifies a comment for the view.", }, - "statement": &schema.Schema{ + "statement": { Type: schema.TypeString, Required: true, Description: "Specifies the query used to create the view.", diff --git a/pkg/resources/view_grant.go b/pkg/resources/view_grant.go index ed3aae2e79..c44020865f 100644 --- a/pkg/resources/view_grant.go +++ b/pkg/resources/view_grant.go @@ -13,25 +13,25 @@ var ValidViewPrivileges = newPrivilegeSet( ) var viewGrantSchema = map[string]*schema.Schema{ - "view_name": &schema.Schema{ + "view_name": { Type: schema.TypeString, Optional: true, Description: "The name of the view on which to grant privileges immediately (only valid if on_future is unset).", ForceNew: true, }, - "schema_name": &schema.Schema{ + "schema_name": { Type: schema.TypeString, Optional: true, Description: "The name of the schema containing the current or future views on which to grant privileges.", ForceNew: true, }, - "database_name": &schema.Schema{ + "database_name": { Type: schema.TypeString, Required: true, Description: "The name of the database containing the current or future views on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the current or future view.", @@ -39,21 +39,21 @@ var viewGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(ValidViewPrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": &schema.Schema{ + "shares": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, Description: "Grants privilege to these shares (only valid if on_future is unset).", ForceNew: true, }, - "on_future": &schema.Schema{ + "on_future": { Type: schema.TypeBool, Optional: true, Description: "When this is set to true and a schema_name is provided, apply this grant on all future views in the given schema. When this is true and no schema_name is provided apply this grant on all future views in the given database. The view_name and shares fields must be unset in order to use on_future.", diff --git a/pkg/resources/warehouse.go b/pkg/resources/warehouse.go index d37ff48486..1da0fd21d8 100644 --- a/pkg/resources/warehouse.go +++ b/pkg/resources/warehouse.go @@ -19,16 +19,16 @@ var warehouseProperties = []string{ } var warehouseSchema = map[string]*schema.Schema{ - "name": &schema.Schema{ + "name": { Type: schema.TypeString, Required: true, }, - "comment": &schema.Schema{ + "comment": { Type: schema.TypeString, Optional: true, Default: "", }, - "warehouse_size": &schema.Schema{ + "warehouse_size": { Type: schema.TypeString, Optional: true, Computed: true, @@ -44,28 +44,28 @@ var warehouseSchema = map[string]*schema.Schema{ return normalize(old) == normalize(new) }, }, - "max_cluster_count": &schema.Schema{ + "max_cluster_count": { Type: schema.TypeInt, Description: "Specifies the maximum number of server clusters for the warehouse.", Optional: true, Computed: true, ValidateFunc: validation.IntBetween(1, 10), }, - "min_cluster_count": &schema.Schema{ + "min_cluster_count": { Type: schema.TypeInt, Description: "Specifies the minimum number of server clusters for the warehouse (only applies to multi-cluster warehouses).", Optional: true, Computed: true, ValidateFunc: validation.IntBetween(1, 10), }, - "scaling_policy": &schema.Schema{ + "scaling_policy": { Type: schema.TypeString, Description: "Specifies the policy for automatically starting and shutting down clusters in a multi-cluster warehouse running in Auto-scale mode.", Optional: true, Computed: true, ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ECONOMY"}, true), }, - "auto_suspend": &schema.Schema{ + "auto_suspend": { Type: schema.TypeInt, Description: "Specifies the number of seconds of inactivity after which a warehouse is automatically suspended.", Optional: true, @@ -73,29 +73,29 @@ var warehouseSchema = map[string]*schema.Schema{ ValidateFunc: validation.IntAtLeast(60), }, // @TODO add a disable_auto_suspend property that sets the value of auto_suspend to NULL - "auto_resume": &schema.Schema{ + "auto_resume": { Type: schema.TypeBool, Description: "Specifies whether to automatically resume a warehouse when a SQL statement (e.g. query) is submitted to it.", Optional: true, Computed: true, }, - "initially_suspended": &schema.Schema{ + "initially_suspended": { Type: schema.TypeBool, Description: "Specifies whether the warehouse is created initially in the ‘Suspended’ state.", Optional: true, }, - "resource_monitor": &schema.Schema{ + "resource_monitor": { Type: schema.TypeString, Description: "Specifies the name of a resource monitor that is explicitly assigned to the warehouse.", Optional: true, Computed: true, }, - "wait_for_provisioning": &schema.Schema{ + "wait_for_provisioning": { Type: schema.TypeBool, Description: "Specifies whether the warehouse, after being resized, waits for all the servers to provision before executing any queued or new queries.", Optional: true, }, - "statement_timeout_in_seconds": &schema.Schema{ + "statement_timeout_in_seconds": { Type: schema.TypeInt, Optional: true, Default: 0, diff --git a/pkg/resources/warehouse_grant.go b/pkg/resources/warehouse_grant.go index af9218bf1b..32baa79b03 100644 --- a/pkg/resources/warehouse_grant.go +++ b/pkg/resources/warehouse_grant.go @@ -15,13 +15,13 @@ var validWarehousePrivileges = newPrivilegeSet( privilegeUsage, ) var warehouseGrantSchema = map[string]*schema.Schema{ - "warehouse_name": &schema.Schema{ + "warehouse_name": { Type: schema.TypeString, Required: true, Description: "The name of the warehouse on which to grant privileges.", ForceNew: true, }, - "privilege": &schema.Schema{ + "privilege": { Type: schema.TypeString, Optional: true, Description: "The privilege to grant on the warehouse.", @@ -29,7 +29,7 @@ var warehouseGrantSchema = map[string]*schema.Schema{ ValidateFunc: validation.StringInSlice(validWarehousePrivileges.toList(), true), ForceNew: true, }, - "roles": &schema.Schema{ + "roles": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true,