Skip to content

Commit

Permalink
feat: allow name to be converted to uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
dgniewek committed Jan 3, 2025
1 parent 7ddff04 commit 2f3b22e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ List od code and variable (API) changes:
| <a name="input_granted_to_roles"></a> [granted\_to\_roles](#input\_granted\_to\_roles) | Roles which this role is granted to | `list(string)` | `[]` | no |
| <a name="input_granted_to_users"></a> [granted\_to\_users](#input\_granted\_to\_users) | Users which this role is granted to | `list(string)` | `[]` | 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-role")<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 | <pre>object({<br> properties = optional(list(string), ["environment", "name"])<br> delimiter = optional(string, "_")<br> context_template_name = optional(string, "snowflake-role")<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_role_ownership_grant"></a> [role\_ownership\_grant](#input\_role\_ownership\_grant) | The name of the role to grant ownership | `string` | `null` | no |
| <a name="input_schema_grants"></a> [schema\_grants](#input\_schema\_grants) | Grants on a schema level | <pre>list(object({<br> all_privileges = optional(bool)<br> with_grant_option = optional(bool, false)<br> privileges = optional(list(string), null)<br> all_schemas_in_database = optional(bool, false)<br> future_schemas_in_database = optional(bool, false)<br> database_name = string<br> schema_name = optional(string, null)<br> }))</pre> | `[]` | no |
| <a name="input_schema_objects_grants"></a> [schema\_objects\_grants](#input\_schema\_objects\_grants) | Grants on a schema object level<br><br> Example usage:<pre>schema_objects_grants = {<br> "TABLE" = [<br> {<br> privileges = ["SELECT"]<br> object_name = snowflake_table.table_1.name<br> schema_name = snowflake_schema.this.name<br> },<br> {<br> all_privileges = true<br> object_name = snowflake_table.table_2.name<br> schema_name = snowflake_schema.this.name<br> }<br> ]<br> "ALERT" = [<br> {<br> all_privileges = true<br> on_future = true<br> on_all = true<br> }<br> ]<br> }</pre>Note: If you don't provide a schema\_name, the grants will be created for all objects of that type in the database.<br> You can find a list of all object types [here](https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/grant_privileges_to_database_role#object_type) | <pre>map(list(object({<br> all_privileges = optional(bool)<br> with_grant_option = optional(bool)<br> privileges = optional(list(string))<br> object_name = optional(string)<br> on_all = optional(bool, false)<br> schema_name = optional(string)<br> database_name = string<br> on_future = optional(bool, false)<br> })))</pre> | `{}` | no |
Expand All @@ -166,15 +166,15 @@ No modules.
| Name | Version |
|------|---------|
| <a name="provider_context"></a> [context](#provider\_context) | >=0.4.0 |
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | ~> 0.94 |
| <a name="provider_snowflake"></a> [snowflake](#provider\_snowflake) | >= 0.94 |

## 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.94 |
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | >= 0.94 |

## Resources

Expand Down
7 changes: 4 additions & 3 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,14 @@ module "snowflake_role_1" {
module "snowflake_role_2" {
source = "../../"

name = "SAMPLE_TEST_2"
name = "sample_test_2"
context_templates = var.context_templates
name_scheme = {
context_template_name = "snowflake-project-role"
extra_values = {
project = "PROJECT"
project = "project"
}
uppercase = false
}

account_grants = [
Expand All @@ -186,7 +187,7 @@ module "snowflake_role_2" {
module "snowflake_role_3" {
source = "../../"

name = "SAMPLE-TEST-3"
name = "sample-test-3"
name_scheme = {
properties = ["name", "schema", "environment"]
delimiter = "_"
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data "context_label" "this" {
}

resource "snowflake_account_role" "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
}
moved {
Expand Down
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ variable "name_scheme" {
context_template_name = optional(string, "snowflake-role")
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.94"
version = ">= 0.94"
}
context = {
source = "cloudposse/context"
Expand Down

0 comments on commit 2f3b22e

Please sign in to comment.