Skip to content

Commit

Permalink
Merge pull request #26 from getindata/feature/add_uppercase_naming_flag
Browse files Browse the repository at this point in the history
feat: Add name_scheme.upper flag, update ci
  • Loading branch information
dgniewek authored Jan 8, 2025
2 parents 4df9214 + effd1b4 commit 579c669
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
10 changes: 4 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
repos:
- repo: https://github.com/gruntwork-io/pre-commit
rev: "v0.1.23" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
rev: "v0.1.25" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
hooks:
- id: terraform-validate # It should be the first step as it runs terraform init required by tflint
- id: terraform-fmt
- id: tflint
# args:
# - "--config=__GIT_ROOT__/.tflint.hcl"

- repo: https://github.com/terraform-docs/terraform-docs
rev: "v0.18.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
rev: "v0.19.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
hooks:
- id: terraform-docs-go
args: ["."]

- repo: https://github.com/bridgecrewio/checkov.git
rev: "3.2.216" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
rev: "3.2.350" # Get the latest from: https://github.com/bridgecrewio/checkov/releases
hooks:
- id: checkov
args: [--skip-check, "CKV_TF_1"] # Terraform module sources do not use a git url with a commit hash revision

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
rev: "v5.0.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
hooks:
- id: check-merge-conflict
args: ["--assume-in-merge"]
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ List od code and variable (API) changes:
| <a name="input_max_concurrency_level"></a> [max\_concurrency\_level](#input\_max\_concurrency\_level) | Object parameter that specifies the concurrency level for SQL statements (i.e. queries and DML) executed by a warehouse. | `number` | `null` | no |
| <a name="input_min_cluster_count"></a> [min\_cluster\_count](#input\_min\_cluster\_count) | Specifies the minimum number of server clusters for the warehouse (only applies to multi-cluster warehouses). | `number` | `1` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the resource | `string` | n/a | yes |
| <a name="input_name_scheme"></a> [name\_scheme](#input\_name\_scheme) | Naming scheme configuration for the resource. This configuration is used to generate names using context provider:<br> - `properties` - list of properties to use when creating the name - is superseded by `var.context_templates`<br> - `delimiter` - delimited used to create the name from `properties` - is superseded by `var.context_templates`<br> - `context_template_name` - name of the context template used to create the name<br> - `replace_chars_regex` - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name<br> - `extra_values` - map of extra label-value pairs, used to create a name | <pre>object({<br> properties = optional(list(string), ["environment", "name"])<br> delimiter = optional(string, "_")<br> context_template_name = optional(string, "snowflake-warehouse")<br> replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")<br> extra_values = optional(map(string))<br> })</pre> | `{}` | no |
| <a name="input_name_scheme"></a> [name\_scheme](#input\_name\_scheme) | Naming scheme configuration for the resource. This configuration is used to generate names using context provider:<br/> - `properties` - list of properties to use when creating the name - is superseded by `var.context_templates`<br/> - `delimiter` - delimited used to create the name from `properties` - is superseded by `var.context_templates`<br/> - `context_template_name` - name of the context template used to create the name<br/> - `replace_chars_regex` - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name<br/> - `extra_values` - map of extra label-value pairs, used to create a name<br/> - `uppercase` - convert name to uppercase | <pre>object({<br/> properties = optional(list(string), ["environment", "name"])<br/> delimiter = optional(string, "_")<br/> context_template_name = optional(string, "snowflake-warehouse")<br/> replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")<br/> extra_values = optional(map(string))<br/> uppercase = optional(bool, true)<br/> })</pre> | `{}` | no |
| <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 |
| <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 |
| <a name="input_roles"></a> [roles](#input\_roles) | Account roles created on the warehouse level | <pre>map(object({<br> name_scheme = optional(object({<br> properties = optional(list(string))<br> delimiter = optional(string)<br> context_template_name = optional(string)<br> replace_chars_regex = optional(string)<br> extra_labels = optional(map(string))<br> }))<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 |
| <a name="input_roles"></a> [roles](#input\_roles) | Account roles created on the warehouse level | <pre>map(object({<br/> name_scheme = optional(object({<br/> properties = optional(list(string))<br/> delimiter = optional(string)<br/> context_template_name = optional(string)<br/> replace_chars_regex = optional(string)<br/> extra_labels = optional(map(string))<br/> uppercase = optional(bool)<br/> }))<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 |
| <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 |
| <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 |
| <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 |
Expand All @@ -128,8 +128,8 @@ List od code and variable (API) changes:
| Name | Source | Version |
|------|--------|---------|
| <a name="module_roles_deep_merge"></a> [roles\_deep\_merge](#module\_roles\_deep\_merge) | Invicton-Labs/deepmerge/null | 0.1.5 |
| <a name="module_snowflake_custom_role"></a> [snowflake\_custom\_role](#module\_snowflake\_custom\_role) | getindata/role/snowflake | 3.0.0 |
| <a name="module_snowflake_default_role"></a> [snowflake\_default\_role](#module\_snowflake\_default\_role) | getindata/role/snowflake | 3.0.0 |
| <a name="module_snowflake_custom_role"></a> [snowflake\_custom\_role](#module\_snowflake\_custom\_role) | getindata/role/snowflake | 3.1.0 |
| <a name="module_snowflake_default_role"></a> [snowflake\_default\_role](#module\_snowflake\_default\_role) | getindata/role/snowflake | 3.1.0 |

## Outputs

Expand Down
1 change: 1 addition & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ module "terraform_snowflake_warehouse_2" {
extra_values = {
project = "project"
}
uppercase = false
}
context_templates = var.context_templates

Expand Down
1 change: 1 addition & 0 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ locals {
prefix = "whs"
warehouse = var.name
}
uppercase = var.name_scheme.uppercase
}

default_roles_definition = {
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data "context_label" "this" {
}

resource "snowflake_warehouse" "this" {
name = data.context_label.this.rendered
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
comment = var.comment

warehouse_size = var.warehouse_size
Expand Down Expand Up @@ -45,7 +45,7 @@ module "snowflake_default_role" {
for_each = local.default_roles #{ for role_name, role in local.default_roles : role_name => role if var.create_default_roles }

source = "getindata/role/snowflake"
version = "3.0.0"
version = "3.1.0"

context_templates = var.context_templates

Expand Down Expand Up @@ -74,7 +74,7 @@ module "snowflake_custom_role" {
for_each = local.custom_roles

source = "getindata/role/snowflake"
version = "3.0.0"
version = "3.1.0"

context_templates = var.context_templates

Expand Down
3 changes: 3 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ variable "roles" {
context_template_name = optional(string)
replace_chars_regex = optional(string)
extra_labels = optional(map(string))
uppercase = optional(bool)
}))
comment = optional(string)
role_ownership_grant = optional(string)
Expand Down Expand Up @@ -135,13 +136,15 @@ variable "name_scheme" {
- `context_template_name` - name of the context template used to create the name
- `replace_chars_regex` - regex to use for replacing characters in property-values created by the provider - any characters that match the regex will be removed from the name
- `extra_values` - map of extra label-value pairs, used to create a name
- `uppercase` - convert name to uppercase
EOT
type = object({
properties = optional(list(string), ["environment", "name"])
delimiter = optional(string, "_")
context_template_name = optional(string, "snowflake-warehouse")
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
extra_values = optional(map(string))
uppercase = optional(bool, true)
})
default = {}
}
Expand Down

0 comments on commit 579c669

Please sign in to comment.