Skip to content

Commit 991ce84

Browse files
authored
fix: make password options deterministic (#5)
1 parent 7e25e3a commit 991ce84

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ This module **does not** create a reader role that can be used to view the data.
2121
| Name | Description | Type | Default | Required |
2222
|------|-------------|------|---------|:--------:|
2323
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The name of the Snowflake database to use | `string` | n/a | yes |
24-
| <a name="input_disable_password"></a> [disable\_password](#input\_disable\_password) | Whether to disable the password for the Snowflake user. If true, the user will only be able to authenticate using the RSA public key. | `bool` | `false` | no |
2524
| <a name="input_fullstory_cidr_ipv4"></a> [fullstory\_cidr\_ipv4](#input\_fullstory\_cidr\_ipv4) | DEPRECATED: Use fullstory\_cidr\_ipv4s. The CIDR block that Fullstory will use to connect to Snowflake. | `string` | `""` | no |
2625
| <a name="input_fullstory_cidr_ipv4s"></a> [fullstory\_cidr\_ipv4s](#input\_fullstory\_cidr\_ipv4s) | The CIDR blocks that Fullstory will use to connect to Snowflake. | `list(string)` | `[]` | no |
2726
| <a name="input_fullstory_data_center"></a> [fullstory\_data\_center](#input\_fullstory\_data\_center) | The data center where your Fullstory account is hosted. Either 'NA1' or 'EU1'. See https://help.fullstory.com/hc/en-us/articles/8901113940375-Fullstory-Data-Residency for more information. | `string` | `"NA1"` | no |
2827
| <a name="input_fullstory_storage_allowed_locations"></a> [fullstory\_storage\_allowed\_locations](#input\_fullstory\_storage\_allowed\_locations) | The list of allowed locations for the storage provider. This is an advanced option and should only be changed if instructed by Fullstory. Ex. <cloud>://<bucket>/<path>/ | `list(string)` | <pre>[<br> "gcs://fullstoryapp-warehouse-sync-bundles"<br>]</pre> | no |
2928
| <a name="input_fullstory_storage_provider"></a> [fullstory\_storage\_provider](#input\_fullstory\_storage\_provider) | The storage provider to use. Either 'S3', 'GCS' or 'AZURE'. This is an advanced option and should only be changed if instructed by Fullstory. | `string` | `"GCS"` | no |
30-
| <a name="input_password"></a> [password](#input\_password) | The password to use for the Snowflake user. | `string` | `null` | no |
29+
| <a name="input_manage_password"></a> [manage\_password](#input\_manage\_password) | Whether to create a random password and use it for the Snowflake user. If false and no password or RSA public key is provided, the user will be created without a password. | `bool` | `true` | no |
30+
| <a name="input_password"></a> [password](#input\_password) | The password to use for the Snowflake user. Use manage\_password=true if you want to generate a random password. | `string` | `null` | no |
3131
| <a name="input_role_name"></a> [role\_name](#input\_role\_name) | The name of the Snowflake role to create. | `string` | `null` | no |
3232
| <a name="input_rsa_public_key"></a> [rsa\_public\_key](#input\_rsa\_public\_key) | The RSA public key to use for the Snowflake user. Must be on 1 line without header and trailer. | `string` | `null` | no |
3333
| <a name="input_rsa_public_key_2"></a> [rsa\_public\_key\_2](#input\_rsa\_public\_key\_2) | The second RSA public key to use for the Snowflake user. Used when rotating keys. Must be on 1 line without header and trailer. | `string` | `null` | no |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "snowflake_grant_privileges_to_role" "warehouse" {
4444
}
4545

4646
resource "random_password" "main" {
47-
count = (var.disable_password || var.password != null) ? 0 : 1
47+
count = var.manage_password ? 1 : 0
4848
length = 16
4949
special = true
5050
override_special = "!#$%&*()-_=+[]{}<>:?"
@@ -55,7 +55,7 @@ resource "snowflake_user" "main" {
5555
name = "FULLSTORY_WAREHOUSE_SETUP_${local.suffix}"
5656
default_warehouse = var.warehouse_name
5757
default_role = snowflake_role.main.name
58-
password = var.disable_password ? "" : (var.password != null ? var.password : random_password.main[0].result)
58+
password = var.manage_password ? random_password.main[0].result : var.password
5959
rsa_public_key = var.rsa_public_key
6060
rsa_public_key_2 = var.rsa_public_key_2
6161
}

variables.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ variable "stage_name" {
1717

1818
variable "password" {
1919
type = string
20-
description = "The password to use for the Snowflake user."
20+
description = "The password to use for the Snowflake user. Use manage_password=true if you want to generate a random password."
2121
default = null
2222
sensitive = true
2323
}
@@ -74,10 +74,10 @@ variable "warehouse_name" {
7474
description = "The name of the Snowflake warehouse to use."
7575
}
7676

77-
variable "disable_password" {
77+
variable "manage_password" {
7878
type = bool
79-
default = false
80-
description = "Whether to disable the password for the Snowflake user. If true, the user will only be able to authenticate using the RSA public key."
79+
default = true
80+
description = "Whether to create a random password and use it for the Snowflake user. If false and no password or RSA public key is provided, the user will be created without a password."
8181
}
8282

8383
variable "rsa_public_key" {

0 commit comments

Comments
 (0)