Skip to content

Commit b12633e

Browse files
authored
Merge pull request #19 from getindata/feat/align_module_with_provider_changes
feat: Align module with snowflake provider changes
2 parents 6762aa9 + 78a7399 commit b12633e

File tree

13 files changed

+85
-70
lines changed

13 files changed

+85
-70
lines changed

.github/workflows/pre-commit.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,3 @@ on:
1212
jobs:
1313
main:
1414
uses: getindata/github-workflows/.github/workflows/tf-pre-commit.yml@v1
15-
with:
16-
# tflint v0.46.0 is the latest version we can use with pre-commit v0.1.20
17-
# See .pre-commit-config.yaml for more details.
18-
tflint-version: v0.46.0

.pre-commit-config.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
repos:
22
- repo: https://github.com/gruntwork-io/pre-commit
3-
# Stick to v0.1.20 until this bug is fixed: https://github.com/gruntwork-io/pre-commit/issues/102
4-
# When updating, also check if tflint version in pre-commit workflow can be updated.
5-
rev: "v0.1.20" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
3+
rev: "v0.1.23" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
64
hooks:
75
- id: terraform-validate # It should be the first step as it runs terraform init required by tflint
86
- id: terraform-fmt
97
- id: tflint
108
args:
11-
- --module
12-
- --config=.tflint.hcl
9+
- "--config=__GIT_ROOT__/.tflint.hcl"
1310

1411
- repo: https://github.com/terraform-docs/terraform-docs
15-
rev: "v0.16.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
12+
rev: "v0.18.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
1613
hooks:
1714
- id: terraform-docs-go
1815
args: ["."]
1916

2017
- repo: https://github.com/bridgecrewio/checkov.git
21-
rev: "2.5.13" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
18+
rev: "3.2.213" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
2219
hooks:
2320
- id: checkov
2421
args: [--skip-check, "CKV_TF_1"] # Terraform module sources do not use a git url with a commit hash revision
2522

2623
- repo: https://github.com/pre-commit/pre-commit-hooks
27-
rev: "v4.5.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
24+
rev: "v4.6.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
2825
hooks:
2926
- id: check-merge-conflict
3027
args: ["--assume-in-merge"]

.tflint.hcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ config {
55
}
66

77
plugin "terraform" {
8-
enabled = true
9-
version = "0.5.0"
10-
source = "github.com/terraform-linters/tflint-ruleset-terraform"
11-
preset = "all"
8+
enabled = true
9+
version = "0.5.0"
10+
source = "github.com/terraform-linters/tflint-ruleset-terraform"
11+
preset = "all"
1212
}
1313

1414
rule "terraform_standard_module_structure" {
15-
enabled = false # Fails on context.tf
15+
enabled = false # Fails on context.tf
1616
}

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Terraform module for Snowflake Warehouse management
2323
* Can create custom Snowflake Roles with role-to-role, role-to-user assignments
2424
* Can create a set of default, functional roles to simplify access management:
2525
* `ADMIN` - full access
26-
* `MODIFY` - abillity to modify warehouse
2726
* `MONITOR` - abillity to monitor warehouse
2827
* `USAGE` - abillity to use warehouse
2928

@@ -56,7 +55,7 @@ module "terraform_snowflake_warehouse" {
5655

5756
## NOTES
5857

59-
_Additional information that should be made public, for ex. how to solve known issues, additional descriptions/suggestions_
58+
When upgrading to version `v2.2.x` - all `default_roles` will be recreated using new terraform resources.
6059

6160
## EXAMPLES
6261

@@ -99,23 +98,23 @@ _Additional information that should be made public, for ex. how to solve known i
9998
| <a name="input_query_acceleration_max_scale_factor"></a> [query\_acceleration\_max\_scale\_factor](#input\_query\_acceleration\_max\_scale\_factor) | Specifies the maximum scale factor for leasing compute resources for query acceleration. The scale factor is used as a multiplier based on warehouse size. | `number` | `null` | no |
10099
| <a name="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.<br>Characters matching the regex will be removed from the ID elements.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
101100
| <a name="input_resource_monitor"></a> [resource\_monitor](#input\_resource\_monitor) | Specifies the name of a resource monitor that is explicitly assigned to the warehouse. | `string` | `null` | no |
102-
| <a name="input_roles"></a> [roles](#input\_roles) | Roles created on the warehouse level | <pre>map(object({<br> enabled = optional(bool, true)<br> descriptor_name = optional(string, "snowflake-role")<br> comment = optional(string)<br> role_ownership_grant = optional(string)<br> granted_roles = optional(list(string))<br> granted_to_roles = optional(list(string))<br> granted_to_users = optional(list(string))<br> warehouse_grants = optional(list(string))<br> }))</pre> | `{}` | no |
103-
| <a name="input_scaling_policy"></a> [scaling\_policy](#input\_scaling\_policy) | Specifies the policy for automatically starting and shutting down clusters in a multi-cluster warehouse running in Auto-scale mode. | `string` | `null` | no |
101+
| <a name="input_roles"></a> [roles](#input\_roles) | Account roles created on the warehouse level | <pre>map(object({<br> enabled = optional(bool, true)<br> descriptor_name = optional(string, "snowflake-role")<br> comment = optional(string)<br> role_ownership_grant = optional(string)<br> granted_roles = optional(list(string))<br> granted_to_roles = optional(list(string))<br> granted_to_users = optional(list(string))<br> warehouse_grants = optional(object({<br> all_privileges = optional(bool)<br> with_grant_option = optional(bool, false)<br> privileges = optional(list(string))<br> }))<br> }))</pre> | `{}` | no |
102+
| <a name="input_scaling_policy"></a> [scaling\_policy](#input\_scaling\_policy) | Specifies the policy for automatically starting and shutting down clusters in a multi-cluster warehouse running in Auto-scale mode. Valid values are `STANDARD` and `ECONOMY`. | `string` | `null` | no |
104103
| <a name="input_stage"></a> [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
105104
| <a name="input_statement_queued_timeout_in_seconds"></a> [statement\_queued\_timeout\_in\_seconds](#input\_statement\_queued\_timeout\_in\_seconds) | Object parameter that specifies the time, in seconds, a SQL statement (query, DDL, DML, etc.) can be queued on a warehouse before it is canceled by the system. | `number` | `null` | no |
106105
| <a name="input_statement_timeout_in_seconds"></a> [statement\_timeout\_in\_seconds](#input\_statement\_timeout\_in\_seconds) | Specifies the time, in seconds, after which a running SQL statement (query, DDL, DML, etc.) is canceled by the system | `number` | `null` | no |
107106
| <a name="input_tags"></a> [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).<br>Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
108107
| <a name="input_tenant"></a> [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
109-
| <a name="input_warehouse_size"></a> [warehouse\_size](#input\_warehouse\_size) | Specifies the size of the virtual warehouse. | `string` | `"X-Small"` | no |
108+
| <a name="input_warehouse_size"></a> [warehouse\_size](#input\_warehouse\_size) | Specifies the size of the virtual warehouse. Possible values are: XSMALL, X-SMALL, SMALL, MEDIUM, LARGE, XLARGE, X-LARGE, XXLARGE, X2LARGE, 2X-LARGE, XXXLARGE, X3LARGE, 3X-LARGE, X4LARGE, 4X-LARGE, X5LARGE, 5X-LARGE, X6LARGE, 6X-LARGE. | `string` | `"X-Small"` | no |
110109
| <a name="input_warehouse_type"></a> [warehouse\_type](#input\_warehouse\_type) | Specifies the type of the virtual warehouse. | `string` | `"STANDARD"` | no |
111110

112111
## Modules
113112

114113
| Name | Source | Version |
115114
|------|--------|---------|
116115
| <a name="module_roles_deep_merge"></a> [roles\_deep\_merge](#module\_roles\_deep\_merge) | Invicton-Labs/deepmerge/null | 0.1.5 |
117-
| <a name="module_snowflake_custom_role"></a> [snowflake\_custom\_role](#module\_snowflake\_custom\_role) | getindata/role/snowflake | 1.0.3 |
118-
| <a name="module_snowflake_default_role"></a> [snowflake\_default\_role](#module\_snowflake\_default\_role) | getindata/role/snowflake | 1.0.3 |
116+
| <a name="module_snowflake_custom_role"></a> [snowflake\_custom\_role](#module\_snowflake\_custom\_role) | getindata/role/snowflake | 2.1.0 |
117+
| <a name="module_snowflake_default_role"></a> [snowflake\_default\_role](#module\_snowflake\_default\_role) | getindata/role/snowflake | 2.1.0 |
119118
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
120119
| <a name="module_warehouse_label"></a> [warehouse\_label](#module\_warehouse\_label) | cloudposse/label/null | 0.25.0 |
121120

@@ -130,21 +129,20 @@ _Additional information that should be made public, for ex. how to solve known i
130129

131130
| Name | Version |
132131
|------|---------|
133-
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.53 |
132+
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.94 |
134133

135134
## Requirements
136135

137136
| Name | Version |
138137
|------|---------|
139138
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
140-
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.53 |
139+
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.94 |
141140

142141
## Resources
143142

144143
| Name | Type |
145144
|------|------|
146145
| [snowflake_warehouse.this](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/warehouse) | resource |
147-
| [snowflake_warehouse_grant.this](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/warehouse_grant) | resource |
148146
<!-- END_TF_DOCS -->
149147

150148
## CONTRIBUTING

examples/complete/main.tf

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
resource "snowflake_role" "this_admin" {
1+
resource "snowflake_account_role" "this_admin" {
22
name = "WAREHOUSE_ADMIN"
33
comment = "Role for Snowflake Administrators"
44
}
55

6-
resource "snowflake_role" "this_dev" {
6+
resource "snowflake_account_role" "this_dev" {
77
name = "WAREHOUSE_DEV"
88
comment = "Role for Snowflake Developers"
99
}
@@ -59,11 +59,19 @@ module "terraform_snowflake_warehouse" {
5959

6060
roles = {
6161
admin = {
62-
granted_to_roles = [snowflake_role.this_admin.name]
62+
granted_to_roles = [snowflake_account_role.this_admin.name]
6363
}
6464
custom_role = {
65-
warehouse_grants = ["USAGE", "MODIFY"]
66-
granted_to_roles = [snowflake_role.this_dev.name]
65+
warehouse_grants = {
66+
privileges = ["USAGE", "MODIFY"]
67+
}
68+
granted_to_roles = [snowflake_account_role.this_dev.name]
6769
}
6870
}
71+
72+
depends_on = [
73+
snowflake_account_role.this_admin,
74+
snowflake_account_role.this_dev,
75+
snowflake_resource_monitor.this
76+
]
6977
}

examples/complete/providers.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/complete/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
snowflake = {
66
source = "Snowflake-Labs/snowflake"
7-
version = "~> 0.47"
7+
version = "~> 0.94"
88
}
99
}
1010
}

examples/simple/providers.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/simple/versions.tf

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
terraform {
22
required_version = ">= 1.3"
3-
4-
required_providers {
5-
snowflake = {
6-
source = "Snowflake-Labs/snowflake"
7-
version = "~> 0.47"
8-
}
9-
}
103
}

locals.tf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,25 @@ locals {
88

99
default_roles_definition = {
1010
usage = {
11-
warehouse_grants = ["USAGE", "OPERATE"]
11+
warehouse_grants = {
12+
all_privileges = null
13+
privileges = ["USAGE", "OPERATE"]
14+
with_grant_option = false
15+
}
1216
}
1317
monitor = {
14-
warehouse_grants = ["MONITOR"]
18+
warehouse_grants = {
19+
privileges = ["MONITOR"]
20+
all_privileges = null
21+
with_grant_option = false
22+
}
1523
}
1624
admin = {
17-
warehouse_grants = ["MODIFY", "MONITOR", "USAGE", "OPERATE", "OWNERSHIP"]
25+
warehouse_grants = {
26+
all_privileges = true
27+
privileges = null
28+
with_grant_option = false
29+
}
1830
}
1931
}
2032

0 commit comments

Comments
 (0)