Skip to content

Commit 6b63603

Browse files
committed
feat: Replace master_password with write only argument equivalent master_password_wo
1 parent 3826756 commit 6b63603

File tree

5 files changed

+94
-78
lines changed

5 files changed

+94
-78
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ No modules.
253253
| <a name="input_database_name"></a> [database\_name](#input\_database\_name) | The name of the first database to be created when the cluster is created. If you do not provide a name, Amazon Redshift will create a default database called `dev` | `string` | `null` | no |
254254
| <a name="input_default_iam_role_arn"></a> [default\_iam\_role\_arn](#input\_default\_iam\_role\_arn) | The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created | `string` | `null` | no |
255255
| <a name="input_elastic_ip"></a> [elastic\_ip](#input\_elastic\_ip) | The Elastic IP (EIP) address for the cluster | `string` | `null` | no |
256-
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If `true`, the data in the cluster is encrypted at rest | `bool` | `true` | no |
256+
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If `true`, the data in the cluster is encrypted at rest | `bool` | `null` | no |
257257
| <a name="input_endpoint_access"></a> [endpoint\_access](#input\_endpoint\_access) | Map of endpoint access (managed VPC endpoint) definitions to create | <pre>map(object({<br/> name = optional(string) # Will fall back to key if not set<br/> resource_owner = optional(string)<br/> subnet_group_name = string<br/> vpc_security_group_ids = optional(list(string))<br/> }))</pre> | `{}` | no |
258258
| <a name="input_enhanced_vpc_routing"></a> [enhanced\_vpc\_routing](#input\_enhanced\_vpc\_routing) | If `true`, enhanced VPC routing is enabled | `bool` | `null` | no |
259259
| <a name="input_final_snapshot_identifier"></a> [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | The identifier of the final snapshot that is to be created immediately before deleting the cluster. If this parameter is provided, `skip_final_snapshot` must be `false` | `string` | `null` | no |
@@ -270,13 +270,14 @@ No modules.
270270
| <a name="input_manage_master_password"></a> [manage\_master\_password](#input\_manage\_master\_password) | Whether to use AWS SecretsManager to manage the cluster admin credentials. Conflicts with `master_password`. One of `master_password` or `manage_master_password` is required unless `snapshot_identifier` is provided | `bool` | `false` | no |
271271
| <a name="input_manage_master_password_rotation"></a> [manage\_master\_password\_rotation](#input\_manage\_master\_password\_rotation) | Whether to manage the master user password rotation. Setting this value to false after previously having been set to true will disable automatic rotation | `bool` | `false` | no |
272272
| <a name="input_manual_snapshot_retention_period"></a> [manual\_snapshot\_retention\_period](#input\_manual\_snapshot\_retention\_period) | The default number of days to retain a manual snapshot. If the value is -1, the snapshot is retained indefinitely. This setting doesn't change the retention period of existing snapshots. Valid values are between `-1` and `3653`. Default value is `-1` | `number` | `null` | no |
273-
| <a name="input_master_password"></a> [master\_password](#input\_master\_password) | Password for the master DB user. (Required unless a `snapshot_identifier` is provided). Must contain at least 8 chars, one uppercase letter, one lowercase letter, and one number | `string` | `null` | no |
274273
| <a name="input_master_password_rotate_immediately"></a> [master\_password\_rotate\_immediately](#input\_master\_password\_rotate\_immediately) | Specifies whether to rotate the secret immediately or wait until the next scheduled rotation window | `bool` | `null` | no |
275274
| <a name="input_master_password_rotation_automatically_after_days"></a> [master\_password\_rotation\_automatically\_after\_days](#input\_master\_password\_rotation\_automatically\_after\_days) | Specifies the number of days between automatic scheduled rotations of the secret. Either `master_user_password_rotation_automatically_after_days` or `master_user_password_rotation_schedule_expression` must be specified | `number` | `null` | no |
276275
| <a name="input_master_password_rotation_duration"></a> [master\_password\_rotation\_duration](#input\_master\_password\_rotation\_duration) | The length of the rotation window in hours. For example, 3h for a three hour window | `string` | `null` | no |
277276
| <a name="input_master_password_rotation_schedule_expression"></a> [master\_password\_rotation\_schedule\_expression](#input\_master\_password\_rotation\_schedule\_expression) | A cron() or rate() expression that defines the schedule for rotating your secret. Either `master_user_password_rotation_automatically_after_days` or `master_user_password_rotation_schedule_expression` must be specified | `string` | `null` | no |
278277
| <a name="input_master_password_secret_kms_key_id"></a> [master\_password\_secret\_kms\_key\_id](#input\_master\_password\_secret\_kms\_key\_id) | ID of the KMS key used to encrypt the cluster admin credentials secret | `string` | `null` | no |
279-
| <a name="input_master_username"></a> [master\_username](#input\_master\_username) | Username for the master DB user (Required unless a `snapshot_identifier` is provided). Defaults to `awsuser` | `string` | `"awsuser"` | no |
278+
| <a name="input_master_password_wo"></a> [master\_password\_wo](#input\_master\_password\_wo) | Password for the master DB user. Must contain at least 8 chars, one uppercase letter, one lowercase letter, and one number | `string` | `null` | no |
279+
| <a name="input_master_password_wo_version"></a> [master\_password\_wo\_version](#input\_master\_password\_wo\_version) | Used together with `master_password_wo` to trigger an update. Increment this value when an update to the `master_password_wo` is required | `string` | `null` | no |
280+
| <a name="input_master_username"></a> [master\_username](#input\_master\_username) | Username for the master DB user. Defaults to `awsuser` | `string` | `"awsuser"` | no |
280281
| <a name="input_multi_az"></a> [multi\_az](#input\_multi\_az) | Specifies if the Redshift cluster is multi-AZ | `bool` | `null` | no |
281282
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | The node type to be provisioned for the cluster | `string` | `""` | no |
282283
| <a name="input_number_of_nodes"></a> [number\_of\_nodes](#input\_number\_of\_nodes) | Number of nodes in the cluster. Defaults to 1. Note: values greater than 1 will trigger `cluster_type` to switch to `multi-node` | `number` | `1` | no |
@@ -288,7 +289,7 @@ No modules.
288289
| <a name="input_parameter_group_tags"></a> [parameter\_group\_tags](#input\_parameter\_group\_tags) | Additional tags to add to the parameter group | `map(string)` | `{}` | no |
289290
| <a name="input_port"></a> [port](#input\_port) | The port number on which the cluster accepts incoming connections. Default port is `5439` | `number` | `5439` | no |
290291
| <a name="input_preferred_maintenance_window"></a> [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range (in UTC) during which automated cluster maintenance can occur. Format: `ddd:hh24:mi-ddd:hh24:mi` | `string` | `"sat:10:00-sat:10:30"` | no |
291-
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | If true, the cluster can be accessed from a public network | `bool` | `false` | no |
292+
| <a name="input_publicly_accessible"></a> [publicly\_accessible](#input\_publicly\_accessible) | If true, the cluster can be accessed from a public network | `bool` | `null` | no |
292293
| <a name="input_region"></a> [region](#input\_region) | Region where the resource(s) will be managed. Defaults to the Region set in the provider configuration | `string` | `null` | no |
293294
| <a name="input_scheduled_actions"></a> [scheduled\_actions](#input\_scheduled\_actions) | Map of scheduled action definitions to create | <pre>map(object({<br/> name = optional(string) # Will fall back to key if not set<br/> description = optional(string)<br/> enable = optional(bool)<br/> start_time = optional(string)<br/> end_time = optional(string)<br/> schedule = string<br/> iam_role = optional(string)<br/> target_action = object({<br/> pause_cluster = optional(bool, false)<br/> resize_cluster = optional(object({<br/> classic = optional(bool)<br/> cluster_type = optional(string)<br/> node_type = optional(string)<br/> number_of_nodes = optional(number)<br/> }))<br/> resume_cluster = optional(bool, false)<br/> })<br/> }))</pre> | `{}` | no |
294295
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | The description of the security group. If value is set to empty string it will contain cluster name in the description | `string` | `null` | no |
@@ -298,9 +299,10 @@ No modules.
298299
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Additional tags for the security group | `map(string)` | `{}` | no |
299300
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether the security group name (`security_group_name`) is used as a prefix | `bool` | `true` | no |
300301
| <a name="input_skip_final_snapshot"></a> [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final snapshot of the cluster is created before Redshift deletes the cluster. If true, a final cluster snapshot is not created. If false , a final cluster snapshot is created before the cluster is deleted | `bool` | `true` | no |
302+
| <a name="input_snapshot_arn"></a> [snapshot\_arn](#input\_snapshot\_arn) | The ARN of the snapshot from which to create the new cluster. Conflicts with `snapshot_identifier` | `string` | `null` | no |
301303
| <a name="input_snapshot_cluster_identifier"></a> [snapshot\_cluster\_identifier](#input\_snapshot\_cluster\_identifier) | The name of the cluster the source snapshot was created from | `string` | `null` | no |
302304
| <a name="input_snapshot_copy"></a> [snapshot\_copy](#input\_snapshot\_copy) | Configuration of automatic copy of snapshots from one region to another | <pre>object({<br/> destination_region = string<br/> manual_snapshot_retention_period = optional(number)<br/> retention_period = optional(number)<br/> grant_name = optional(string)<br/> })</pre> | `null` | no |
303-
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster | `string` | `null` | no |
305+
| <a name="input_snapshot_identifier"></a> [snapshot\_identifier](#input\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster. Conflicts with `snapshot_arn` | `string` | `null` | no |
304306
| <a name="input_snapshot_schedule"></a> [snapshot\_schedule](#input\_snapshot\_schedule) | Configuration for creating a snapshot schedule and associating it with the cluster | <pre>object({<br/> definitions = list(string)<br/> description = optional(string)<br/> force_destroy = optional(bool)<br/> use_prefix = optional(bool, false)<br/> identifier = optional(string)<br/> tags = optional(map(string), {})<br/> })</pre> | `null` | no |
305307
| <a name="input_subnet_group_description"></a> [subnet\_group\_description](#input\_subnet\_group\_description) | The description of the Redshift Subnet group. Defaults to `Managed by Terraform` | `string` | `null` | no |
306308
| <a name="input_subnet_group_name"></a> [subnet\_group\_name](#input\_subnet\_group\_name) | The name of the Redshift subnet group, existing or to be created | `string` | `null` | no |

docs/UPGRADE-7.0.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Please consult the `examples` directory for reference example configurations. If
77
- Terraform `v1.11` is now minimum supported version to support write-only (`wo_*`) attributes.
88
- AWS provider `v6.18` is now minimum supported version
99
- The ability for the module to create a random password has been removed in order to ensure passwords are not stored in plain text within the state file. Users must now provide their own password via the `master_password_wo` variable.
10+
- `master_password` is no longer supported and only the write-only equivalent is supported (`master_password_wo` and `master_password_wo_version`)
1011

1112
## Additional changes
1213

@@ -47,7 +48,7 @@ Please consult the `examples` directory for reference example configurations. If
4748

4849
2. Renamed variables:
4950

50-
-
51+
- `master_password` -> `master_password_wo`
5152

5253
3. Added variables:
5354

@@ -59,6 +60,7 @@ Please consult the `examples` directory for reference example configurations. If
5960
- `vpc_id`
6061
- `security_group_ingress_rules`
6162
- `security_group_egress_rules`
63+
- `master_password_wo_version`
6264

6365
4. Removed outputs:
6466

main.tf

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,34 @@ resource "aws_redshift_cluster" "this" {
2828
enhanced_vpc_routing = var.enhanced_vpc_routing
2929
final_snapshot_identifier = var.skip_final_snapshot ? null : var.final_snapshot_identifier
3030
kms_key_id = var.kms_key_arn
31-
32-
# iam_roles and default_iam_roles are managed in the aws_redshift_cluster_iam_roles resource below
33-
34-
maintenance_track_name = var.maintenance_track_name
35-
manual_snapshot_retention_period = var.manual_snapshot_retention_period
36-
manage_master_password = var.manage_master_password ? var.manage_master_password : null
37-
master_password = var.snapshot_identifier == null && !var.manage_master_password ? var.master_password : null
38-
master_password_secret_kms_key_id = var.master_password_secret_kms_key_id
39-
master_username = var.master_username
40-
multi_az = var.multi_az
41-
node_type = var.node_type
42-
number_of_nodes = var.number_of_nodes
43-
owner_account = var.owner_account
44-
port = var.port
45-
preferred_maintenance_window = var.preferred_maintenance_window
46-
publicly_accessible = var.publicly_accessible
47-
skip_final_snapshot = var.skip_final_snapshot
48-
snapshot_cluster_identifier = var.snapshot_cluster_identifier
49-
50-
snapshot_identifier = var.snapshot_identifier
51-
vpc_security_group_ids = compact(concat(aws_security_group.this[*].id, var.vpc_security_group_ids))
52-
53-
tags = var.tags
31+
maintenance_track_name = var.maintenance_track_name
32+
manage_master_password = var.manage_master_password ? var.manage_master_password : null
33+
manual_snapshot_retention_period = var.manual_snapshot_retention_period
34+
master_password_wo = var.snapshot_identifier == null && !var.manage_master_password ? var.master_password_wo : null
35+
master_password_wo_version = var.snapshot_identifier == null && !var.manage_master_password ? var.master_password_wo_version : null
36+
master_password_secret_kms_key_id = var.master_password_secret_kms_key_id
37+
master_username = var.master_username
38+
multi_az = var.multi_az
39+
node_type = var.node_type
40+
number_of_nodes = var.number_of_nodes
41+
owner_account = var.owner_account
42+
port = var.port
43+
preferred_maintenance_window = var.preferred_maintenance_window
44+
publicly_accessible = var.publicly_accessible
45+
skip_final_snapshot = var.skip_final_snapshot
46+
snapshot_arn = var.snapshot_arn
47+
snapshot_cluster_identifier = var.snapshot_cluster_identifier
48+
snapshot_identifier = var.snapshot_identifier
49+
tags = var.tags
50+
vpc_security_group_ids = compact(concat(aws_security_group.this[*].id, var.vpc_security_group_ids))
5451

5552
dynamic "timeouts" {
56-
for_each = var.cluster_timeouts != null ? [1] : []
53+
for_each = var.cluster_timeouts != null ? [var.cluster_timeouts] : []
5754

5855
content {
59-
create = var.cluster_timeouts.create
60-
update = var.cluster_timeouts.update
61-
delete = var.cluster_timeouts.delete
56+
create = each.value.create
57+
update = each.value.update
58+
delete = each.value.delete
6259
}
6360
}
6461

0 commit comments

Comments
 (0)