Skip to content

Commit dd8ac93

Browse files
authored
Merge pull request #20 from getindata/fix/context_provider_configuration
fix: Context provider configuration logic
2 parents d8773fb + 8714898 commit dd8ac93

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ module "snowflake_storage_integration" {
8888
| <a name="input_create_default_roles"></a> [create\_default\_roles](#input\_create\_default\_roles) | Whether the default roles should be created | `bool` | `false` | no |
8989
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Whether the storage integration is enabled | `bool` | `true` | no |
9090
| <a name="input_name"></a> [name](#input\_name) | Name of the resource | `string` | n/a | yes |
91-
| <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 |
91+
| <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-storage-integration")<br/> replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")<br/> extra_values = optional(map(string))<br/> uppercase = optional(bool, true)<br/> })</pre> | `{}` | no |
9292
| <a name="input_roles"></a> [roles](#input\_roles) | Roles created in the database scope | <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/> integration_grants = optional(object({<br/> all_privileges = optional(bool)<br/> with_grant_option = optional(bool, false)<br/> privileges = optional(list(string))<br/> }))<br/> }))</pre> | `{}` | no |
9393
| <a name="input_storage_allowed_locations"></a> [storage\_allowed\_locations](#input\_storage\_allowed\_locations) | Explicitly limits external stages that use the integration to reference one or more storage locations | `list(string)` | n/a | yes |
9494
| <a name="input_storage_aws_object_acl"></a> [storage\_aws\_object\_acl](#input\_storage\_aws\_object\_acl) | Value of "bucket-owner-full-control" enables support for AWS access control lists (ACLs) to grant the bucket owner full control | `string` | `null` | no |

examples/complete/fixtures.tfvars

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
context_templates = {
2-
snowflake-storage-integration = "{{.name}}"
3-
snowflalake-storage-integration-role = "{{.prefix}}_{{.storage-integration}}_{{.name}}"
2+
snowflake-storage-integration = "{{.name}}"
3+
snowflake-storage-integration-role = "{{.prefix}}_{{.integration}}_{{.name}}"
44
}

locals.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ locals {
22
context_template = lookup(var.context_templates, var.name_scheme.context_template_name, null)
33

44
default_role_naming_scheme = {
5-
properties = ["prefix", "environment", "storage-integration", "name"]
5+
properties = ["prefix", "environment", "integration", "name"]
66
context_template_name = "snowflake-storage-integration-role"
77
extra_values = {
8-
prefix = "sti"
9-
storage-integration = var.name
8+
prefix = "sti"
9+
integration = var.name
1010
}
1111
uppercase = var.name_scheme.uppercase
1212
}

main.tf

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module "snowflake_default_role" {
4242
name = each.key
4343
name_scheme = merge(
4444
local.default_role_naming_scheme,
45-
lookup(each.value, "name_scheme", {})
45+
{ for k, v in lookup(each.value, "name_scheme", {}) : k => v if v != null }
4646
)
4747

4848
role_ownership_grant = lookup(each.value, "role_ownership_grant", "SYSADMIN")
@@ -71,7 +71,7 @@ module "snowflake_custom_role" {
7171
name = each.key
7272
name_scheme = merge(
7373
local.default_role_naming_scheme,
74-
lookup(each.value, "name_scheme", {})
74+
{ for k, v in lookup(each.value, "name_scheme", {}) : k => v if v != null }
7575
)
7676
granted_to_users = lookup(each.value, "granted_to_users", [])
7777
granted_to_roles = lookup(each.value, "granted_to_roles", [])

variables.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ variable "name_scheme" {
104104
type = object({
105105
properties = optional(list(string), ["environment", "name"])
106106
delimiter = optional(string, "_")
107-
context_template_name = optional(string, "snowflake-warehouse")
107+
context_template_name = optional(string, "snowflake-storage-integration")
108108
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
109109
extra_values = optional(map(string))
110110
uppercase = optional(bool, true)

0 commit comments

Comments
 (0)