Skip to content

Commit d5ec21f

Browse files
committed
feat: add name_scheme.uppercase flag + bump submodules + minor fixes and upgrades
1 parent eb35965 commit d5ec21f

File tree

9 files changed

+44
-20
lines changed

9 files changed

+44
-20
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
repos:
22
- repo: https://github.com/gruntwork-io/pre-commit
33
# When updating, also check if tflint version in pre-commit workflow can be updated.
4-
rev: "v0.1.23" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
4+
rev: "v0.1.25" # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
55
hooks:
66
- id: terraform-validate # It should be the first step as it runs terraform init required by tflint
77
- id: terraform-fmt
88
- id: tflint
99

1010
- repo: https://github.com/terraform-docs/terraform-docs
11-
rev: "v0.18.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
11+
rev: "v0.19.0" # Get the latest from: https://github.com/terraform-docs/terraform-docs/releases
1212
hooks:
1313
- id: terraform-docs-go
1414
args: ["."]
1515

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

2222
- repo: https://github.com/pre-commit/pre-commit-hooks
23-
rev: "v4.6.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
23+
rev: "v5.0.0" # Get the latest from: https://github.com/pre-commit/pre-commit-hooks/releases
2424
hooks:
2525
- id: check-merge-conflict
2626
args: ["--assume-in-merge"]

README.md

Lines changed: 8 additions & 8 deletions
Large diffs are not rendered by default.

examples/complete/main.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ module "database" {
3535
stages = {
3636
example = {
3737
comment = "my example stage"
38+
name_scheme = {
39+
uppercase = false
40+
}
3841
}
3942
}
4043
roles = {
@@ -43,6 +46,9 @@ module "database" {
4346
}
4447
readonly = {
4548
granted_to_roles = [snowflake_account_role.dev_role.name]
49+
name_scheme = {
50+
uppercase = false
51+
}
4652
}
4753
}
4854
}
@@ -74,5 +80,14 @@ module "project_database" {
7480
extra_values = {
7581
project = "project"
7682
}
83+
uppercase = false
7784
}
85+
86+
87+
comment = "test database"
88+
data_retention_time_in_days = 1
89+
is_transient = false
90+
91+
create_default_roles = true
92+
database_ownership_grant = snowflake_account_role.admin_role.name
7893
}

examples/simple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ No providers.
4141
| Name | Version |
4242
|------|---------|
4343
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
44-
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | ~> 0.95 |
44+
| <a name="requirement_snowflake"></a> [snowflake](#requirement\_snowflake) | >= 0.95 |
4545

4646
## Resources
4747

examples/simple/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
snowflake = {
55
source = "Snowflake-Labs/snowflake"
6-
version = "~> 0.95"
6+
version = ">= 0.95"
77
}
88
}
99
}

locals.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ locals {
77
extra_values = {
88
database = var.name
99
}
10+
uppercase = var.name_scheme.uppercase
1011
}
1112

1213
#This needs to be the same as an object in roles variable

main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ data "context_label" "this" {
1212
}
1313

1414
resource "snowflake_database" "this" {
15-
name = data.context_label.this.rendered
15+
name = var.name_scheme.uppercase ? upper(data.context_label.this.rendered) : data.context_label.this.rendered
1616
is_transient = var.is_transient
1717
comment = var.comment
1818

@@ -43,7 +43,7 @@ module "snowflake_default_role" {
4343
for_each = local.default_roles
4444

4545
source = "getindata/database-role/snowflake"
46-
version = "2.0.1"
46+
version = "2.1.0"
4747

4848
database_name = snowflake_database.this.name
4949
context_templates = var.context_templates
@@ -67,7 +67,7 @@ module "snowflake_custom_role" {
6767
for_each = local.custom_roles
6868

6969
source = "getindata/database-role/snowflake"
70-
version = "2.0.1"
70+
version = "2.1.0"
7171

7272
database_name = snowflake_database.this.name
7373
context_templates = var.context_templates
@@ -91,12 +91,13 @@ module "snowflake_schema" {
9191
for_each = var.schemas
9292

9393
source = "getindata/schema/snowflake"
94-
version = "3.0.0"
94+
version = "3.1.0"
9595

9696
context_templates = var.context_templates
9797

9898
name = each.key
9999
name_scheme = merge({
100+
uppercase = var.name_scheme.uppercase
100101
extra_values = {
101102
database = var.name
102103
} },
@@ -137,7 +138,7 @@ resource "snowflake_grant_ownership" "database_ownership" {
137138
count = var.database_ownership_grant != null ? 1 : 0
138139

139140
account_role_name = var.database_ownership_grant
140-
outbound_privileges = "REVOKE"
141+
outbound_privileges = "COPY"
141142
on {
142143
object_type = "DATABASE"
143144
object_name = snowflake_database.this.name

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ variable "roles" {
126126
context_template_name = optional(string)
127127
replace_chars_regex = optional(string)
128128
extra_labels = optional(map(string))
129+
uppercase = optional(bool)
129130
}))
130131
comment = optional(string)
131132
role_ownership_grant = optional(string)
@@ -167,6 +168,7 @@ variable "schemas" {
167168
context_template_name = optional(string)
168169
replace_chars_regex = optional(string)
169170
extra_labels = optional(map(string))
171+
uppercase = optional(bool)
170172
}))
171173
skip_schema_creation = optional(bool, false)
172174
comment = optional(string, null)
@@ -197,6 +199,7 @@ variable "schemas" {
197199
context_template_name = optional(string)
198200
replace_chars_regex = optional(string)
199201
extra_labels = optional(map(string))
202+
uppercase = optional(bool)
200203
}))
201204
aws_external_id = optional(string)
202205
comment = optional(string)
@@ -216,6 +219,7 @@ variable "schemas" {
216219
context_template_name = optional(string)
217220
replace_chars_regex = optional(string)
218221
extra_labels = optional(map(string))
222+
uppercase = optional(bool)
219223
}))
220224
with_grant_option = optional(bool)
221225
granted_to_roles = optional(list(string))
@@ -232,6 +236,7 @@ variable "schemas" {
232236
context_template_name = optional(string)
233237
replace_chars_regex = optional(string)
234238
extra_labels = optional(map(string))
239+
uppercase = optional(bool)
235240
}))
236241
comment = optional(string)
237242
granted_to_roles = optional(list(string))
@@ -275,13 +280,15 @@ variable "name_scheme" {
275280
- `context_template_name` - name of the context template used to create the name
276281
- `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
277282
- `extra_values` - map of extra label-value pairs, used to create a name
283+
- `uppercase` - convert name to uppercase
278284
EOT
279285
type = object({
280286
properties = optional(list(string), ["environment", "name"])
281287
delimiter = optional(string, "_")
282288
context_template_name = optional(string, "snowflake-database")
283289
replace_chars_regex = optional(string, "[^a-zA-Z0-9_]")
284290
extra_values = optional(map(string))
291+
uppercase = optional(bool, true)
285292
})
286293
default = {}
287294
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
snowflake = {
55
source = "Snowflake-Labs/snowflake"
6-
version = "~> 0.95"
6+
version = ">= 0.95"
77
}
88
context = {
99
source = "cloudposse/context"

0 commit comments

Comments
 (0)