Skip to content

Commit

Permalink
Merge pull request #21 from getindata/feature/add_upper_naming_flag
Browse files Browse the repository at this point in the history
feat: Add `name_scheme.upper` flag, allow newer snowflake provider versions, update ci
  • Loading branch information
dgniewek authored Jan 7, 2025
2 parents e8f623a + a8b063e commit ccf8048
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 20 deletions.
6 changes: 2 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
repos:
- repo: https://github.com/gruntwork-io/pre-commit
# When updating, also check if tflint version in pre-commit workflow can be updated.
rev: "v0.1.24" # 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.19.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
Expand All @@ -16,7 +14,7 @@ repos:
args: ["."]

- repo: https://github.com/bridgecrewio/checkov.git
rev: "3.2.269" # 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
Expand Down
3 changes: 0 additions & 3 deletions .tflint.hcl

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ List od code and variable (API) changes:
| <a name="input_middle_name"></a> [middle\_name](#input\_middle\_name) | Middle name of the user (works only with `type = PERSON`) | `string` | `null` | no |
| <a name="input_must_change_password"></a> [must\_change\_password](#input\_must\_change\_password) | Should the user change the password on login. Should be set to true for non service account users | `bool` | `true` | 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-user")<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-user")<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_network_policy"></a> [network\_policy](#input\_network\_policy) | Specifies the network policy to enforce for your account. Network policies enable restricting access to your account based on users’ IP address. | `string` | `null` | no |
| <a name="input_query_tag"></a> [query\_tag](#input\_query\_tag) | Optional string that can be used to tag queries and other SQL statements executed within a session. | `string` | `null` | no |
| <a name="input_rsa_public_key"></a> [rsa\_public\_key](#input\_rsa\_public\_key) | Specifies the user's RSA public key; used for key-pair authentication. Must be on 1 line without header and trailer. | `string` | `null` | no |
Expand Down Expand Up @@ -156,7 +156,7 @@ No modules.
|------|---------|
| <a name="provider_context"></a> [context](#provider\_context) | >=0.4.0 |
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.0.0 |
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.96 |
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | >= 0.96 |
| <a name="provider_tls"></a> [tls](#provider\_tls) | ~> 4.0 |

## Requirements
Expand All @@ -166,7 +166,7 @@ No modules.
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
| <a name="requirement_context"></a> [context](#requirement\_context) | >=0.4.0 |
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.0.0 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.96 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | >= 0.96 |
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | ~> 4.0 |

## Resources
Expand Down
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ terraform destroy -var-file=fixtures.tfvars

| Name | Version |
|------|---------|
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.96 |
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | >= 0.96 |

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_context"></a> [context](#requirement\_context) | 0.4.0 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.96 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | >= 0.96 |

## Resources

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

Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.96"
version = ">= 0.96"
}
context = {
source = "cloudposse/context"
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ No providers.
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
| <a name="requirement_context"></a> [context](#requirement\_context) | >=0.4.0 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.96 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | >= 0.96 |

## Resources

Expand Down
2 changes: 1 addition & 1 deletion examples/simple/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.96"
version = ">= 0.96"
}
context = {
source = "cloudposse/context"
Expand Down
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resource "random_password" "this" {
resource "snowflake_user" "this" {
count = !var.ignore_changes_on_defaults && upper(var.type) == "PERSON" ? 1 : 0

name = data.context_label.this.rendered
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
login_name = var.login_name
display_name = var.display_name
comment = var.comment
Expand Down Expand Up @@ -64,7 +64,7 @@ resource "snowflake_user" "this" {
resource "snowflake_user" "defaults_not_enforced" {
count = var.ignore_changes_on_defaults && upper(var.type) == "PERSON" ? 1 : 0

name = data.context_label.this.rendered
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
login_name = var.login_name
display_name = var.display_name
comment = var.comment
Expand Down Expand Up @@ -107,7 +107,7 @@ resource "snowflake_user" "defaults_not_enforced" {
resource "snowflake_service_user" "this" {
count = upper(var.type) == "SERVICE" ? 1 : 0

name = data.context_label.this.rendered
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
login_name = var.login_name
display_name = var.display_name

Expand Down Expand Up @@ -135,7 +135,7 @@ resource "snowflake_service_user" "this" {
resource "snowflake_legacy_service_user" "this" {
count = upper(var.type) == "LEGACY_SERVICE" ? 1 : 0

name = data.context_label.this.rendered
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
login_name = var.login_name
display_name = var.display_name
disabled = var.disabled
Expand Down
2 changes: 2 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,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-user")
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
extra_values = optional(map(string))
uppercase = optional(bool, true)
})
default = {}
}
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.96"
version = ">= 0.96"
}
tls = {
source = "hashicorp/tls"
Expand Down

0 comments on commit ccf8048

Please sign in to comment.