Skip to content

Commit 6d44036

Browse files
authored
Merge pull request #14 from getindata/feature/align_module_with_provider_changes
feat!: Align module with latest Snowflake provider changes
2 parents 4cf1e5c + 89bce4d commit 6d44036

File tree

12 files changed

+172
-43
lines changed

12 files changed

+172
-43
lines changed

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
main:
1414
uses: getindata/github-workflows/.github/workflows/tf-pre-commit.yml@v1
1515
with:
16-
# tflint v0.46.0 is the latest version we can use with pre-commit v0.1.20
16+
# tflint v0.52.0 is the latest version we can use with pre-commit v0.1.23
1717
# See .pre-commit-config.yaml for more details.
18-
tflint-version: v0.46.0
18+
tflint-version: v0.52.0

.pre-commit-config.yaml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
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
43
# 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
4+
rev: "v0.1.23" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
65
hooks:
76
- id: terraform-validate # It should be the first step as it runs terraform init required by tflint
87
- id: terraform-fmt
98
- id: tflint
109
args:
11-
- --module
12-
- --config=.tflint.hcl
10+
- "--config=__GIT_ROOT__/.tflint.hcl"
1311

1412
- 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
13+
rev: "v0.18.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
1614
hooks:
1715
- id: terraform-docs-go
1816
args: ["."]
1917

2018
- repo: https://github.com/bridgecrewio/checkov.git
21-
rev: "2.5.13" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
19+
rev: "3.2.192" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
2220
hooks:
2321
- id: checkov
2422
args: [--skip-check, "CKV_TF_1"] # Terraform module sources do not use a git url with a commit hash revision
2523

2624
- 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
25+
rev: "v4.6.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
2826
hooks:
2927
- id: check-merge-conflict
3028
args: ["--assume-in-merge"]

.terraform-docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ sections:
66
hide: []
77
show: [all]
88

9+
recursive:
10+
enabled: true
11+
path: examples
12+
913
content: |-
1014
{{ .Header }}
1115

.tflint.hcl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugin "terraform" {
2-
enabled = true
3-
version = "0.5.0"
4-
source = "github.com/terraform-linters/tflint-ruleset-terraform"
5-
preset = "all"
2+
enabled = true
3+
version = "0.5.0"
4+
source = "github.com/terraform-linters/tflint-ruleset-terraform"
5+
preset = "all"
66
}
77

88
rule "terraform_standard_module_structure" {
9-
enabled = false # Fails on context.tf
9+
enabled = false # Fails on context.tf
1010
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ module "terraform_snowflake_user" {
105105
| Name | Version |
106106
|------|---------|
107107
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0.0 |
108-
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.54 |
108+
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.94 |
109109
| <a name="provider_tls"></a> [tls](#provider\_tls) | ~> 4.0 |
110110

111111
## Requirements
@@ -114,15 +114,15 @@ module "terraform_snowflake_user" {
114114
|------|---------|
115115
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
116116
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0.0 |
117-
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.54 |
117+
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.94 |
118118
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | ~> 4.0 |
119119

120120
## Resources
121121

122122
| Name | Type |
123123
|------|------|
124124
| [random_password.this](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |
125-
| [snowflake_role_grants.default_role](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/role_grants) | resource |
125+
| [snowflake_grant_account_role.default_role](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_account_role) | resource |
126126
| [snowflake_user.defaults_not_enforced](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/user) | resource |
127127
| [snowflake_user.this](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/user) | resource |
128128
| [tls_private_key.this](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/resources/private_key) | resource |

examples/complete/README.md

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,90 @@
11
# Complete Example
22

3-
```terraform
4-
module "terraform_snowflake_user" {
5-
source = "../../"
6-
context = module.this.context
7-
name = "snowflake-user"
8-
}
9-
```
3+
This is complete usage example of `snowflake-user` terraform module.
104

115
## Usage
6+
Populate `.env` file with Snowflake credentials and make sure it's sourced to your shell.
7+
8+
## How to plan
9+
10+
```shell
11+
terraform init
12+
terraform plan -var-file=fixtures.tfvars
1213
```
14+
15+
## How to apply
16+
17+
```shell
1318
terraform init
14-
terraform plan -var-file fixtures.tfvars -out tfplan
15-
terraform apply tfplan
19+
terraform apply -var-file=fixtures.tfvars
1620
```
21+
22+
## How to destroy
23+
24+
```shell
25+
terraform destroy -var-file=fixtures.tfvars
26+
```
27+
28+
29+
<!-- BEGIN_TF_DOCS -->
30+
31+
32+
33+
34+
## Inputs
35+
36+
| Name | Description | Type | Default | Required |
37+
|------|-------------|------|---------|:--------:|
38+
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br>This is for some rare cases where resources want additional configuration of tags<br>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
39+
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br>in the order they appear in the list. New attributes are appended to the<br>end of the list. The elements of the list are joined by the `delimiter`<br>and treated as a single ID element. | `list(string)` | `[]` | no |
40+
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "descriptor_formats": {},<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_key_case": null,<br> "label_order": [],<br> "label_value_case": null,<br> "labels_as_tags": [<br> "unset"<br> ],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {},<br> "tenant": null<br>}</pre> | no |
41+
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
42+
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br>Map of maps. Keys are names of descriptors. Values are maps of the form<br>`{<br> format = string<br> labels = list(string)<br>}`<br>(Type is `any` so the map values can later be enhanced to provide additional options.)<br>`format` is a Terraform format string to be passed to the `format()` function.<br>`labels` is a list of labels, in order, to pass to `format()` function.<br>Label values will be normalized before being passed to `format()` so they will be<br>identical to how they appear in `id`.<br>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
43+
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
44+
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
45+
| <a name="input_id_length_limit"></a> [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).<br>Set to `0` for unlimited length.<br>Set to `null` for keep the existing setting, which defaults to `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
46+
| <a name="input_label_key_case"></a> [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.<br>Does not affect keys of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper`.<br>Default value: `title`. | `string` | `null` | no |
47+
| <a name="input_label_order"></a> [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
48+
| <a name="input_label_value_case"></a> [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,<br>set as tag values, and output by this module individually.<br>Does not affect values of tags passed in via the `tags` input.<br>Possible values: `lower`, `title`, `upper` and `none` (no transformation).<br>Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.<br>Default value: `lower`. | `string` | `null` | no |
49+
| <a name="input_labels_as_tags"></a> [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.<br>Default is to include all labels.<br>Tags with empty values will not be included in the `tags` output.<br>Set to `[]` to suppress all generated tags.<br>**Notes:**<br> The value of the `name` tag, if included, will be the `id`, not the `name`.<br> Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be<br> changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | <pre>[<br> "default"<br>]</pre> | no |
50+
| <a name="input_name"></a> [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.<br>This is the only ID element not also included as a `tag`.<br>The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
51+
| <a name="input_namespace"></a> [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
52+
| <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 |
53+
| <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 |
54+
| <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 |
55+
| <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 |
56+
57+
## Modules
58+
59+
| Name | Source | Version |
60+
|------|--------|---------|
61+
| <a name="module_terraform_snowflake_user_1"></a> [terraform\_snowflake\_user\_1](#module\_terraform\_snowflake\_user\_1) | ../../ | n/a |
62+
| <a name="module_terraform_snowflake_user_2"></a> [terraform\_snowflake\_user\_2](#module\_terraform\_snowflake\_user\_2) | ../../ | n/a |
63+
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
64+
65+
## Outputs
66+
67+
| Name | Description |
68+
|------|-------------|
69+
| <a name="output_user_module_outputs_1"></a> [user\_module\_outputs\_1](#output\_user\_module\_outputs\_1) | All user module outputs |
70+
| <a name="output_user_module_outputs_2"></a> [user\_module\_outputs\_2](#output\_user\_module\_outputs\_2) | All user module outputs |
71+
72+
## Providers
73+
74+
| Name | Version |
75+
|------|---------|
76+
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.94 |
77+
78+
## Requirements
79+
80+
| Name | Version |
81+
|------|---------|
82+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
83+
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.94 |
84+
85+
## Resources
86+
87+
| Name | Type |
88+
|------|------|
89+
| [snowflake_account_role.user_role](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/account_role) | resource |
90+
<!-- END_TF_DOCS -->

examples/complete/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resource "snowflake_role" "user_role" {
1+
resource "snowflake_account_role" "user_role" {
22
name = "SNOWFLAKE_USER_ROLE"
33
}
44

@@ -9,7 +9,7 @@ module "terraform_snowflake_user_1" {
99
generate_rsa_key = true
1010
generate_password = true
1111

12-
default_role = resource.snowflake_role.user_role.name
12+
default_role = resource.snowflake_account_role.user_role.name
1313
default_secondary_roles = ["ALL"]
1414
}
1515

@@ -22,6 +22,6 @@ module "terraform_snowflake_user_2" {
2222
ignore_changes_on_defaults = false
2323
grant_default_roles = true
2424

25-
default_role = resource.snowflake_role.user_role.name
25+
default_role = resource.snowflake_account_role.user_role.name
2626
default_secondary_roles = ["ALL"]
2727
}

examples/complete/versions.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
terraform {
22
required_version = ">= 1.3"
3+
34
required_providers {
45
snowflake = {
56
source = "Snowflake-Labs/snowflake"
6-
version = "~> 0.54"
7+
version = "~> 0.94"
78
}
89
}
910
}

examples/simple/README.md

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,65 @@
1-
# Simple Example
1+
# Simple example
22

3-
```terraform
4-
module "terraform_snowflake_user" {
5-
source = "../../"
6-
name = "snowflake-user"
7-
}
8-
```
3+
This is simple usage example of `snowflake-user` terraform module.
94

105
## Usage
6+
Populate `.env` file with Snowflake credentials and make sure it's sourced to your shell.
7+
8+
## How to plan
9+
10+
```shell
11+
terraform init
12+
terraform plan
1113
```
14+
15+
## How to apply
16+
17+
```shell
1218
terraform init
13-
terraform plan -out tfplan
14-
terraform apply tfplan
19+
terraform apply
1520
```
21+
22+
## How to destroy
23+
24+
```shell
25+
terraform destroy
26+
```
27+
28+
<!-- BEGIN_TF_DOCS -->
29+
30+
31+
32+
33+
## Inputs
34+
35+
No inputs.
36+
37+
## Modules
38+
39+
| Name | Source | Version |
40+
|------|--------|---------|
41+
| <a name="module_terraform_snowflake_user"></a> [terraform\_snowflake\_user](#module\_terraform\_snowflake\_user) | ../../ | n/a |
42+
43+
## Outputs
44+
45+
| Name | Description |
46+
|------|-------------|
47+
| <a name="output_default_role"></a> [default\_role](#output\_default\_role) | Specifies the role that is active by default for the user's session upon login |
48+
| <a name="output_display_name"></a> [display\_name](#output\_display\_name) | Specifies the namespace (database only or database and schema) that is active by default for the user's session upon login |
49+
| <a name="output_login_name"></a> [login\_name](#output\_login\_name) | The name users use to log in |
50+
51+
## Providers
52+
53+
No providers.
54+
55+
## Requirements
56+
57+
| Name | Version |
58+
|------|---------|
59+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
60+
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.94 |
61+
62+
## Resources
63+
64+
No resources.
65+
<!-- END_TF_DOCS -->

examples/simple/versions.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
terraform {
22
required_version = ">= 1.3"
3+
34
required_providers {
45
snowflake = {
56
source = "Snowflake-Labs/snowflake"
6-
version = "~> 0.54"
7+
version = "~> 0.94"
78
}
89
}
910
}

0 commit comments

Comments
 (0)