Skip to content

Commit fce3dc0

Browse files
authored
feat: Allow parameter group key to be used as parameter group name, add outpust for cluster master password and username (#109)
1 parent 51c93ff commit fce3dc0

File tree

6 files changed

+37
-4
lines changed

6 files changed

+37
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ No modules.
319319
| <a name="output_cluster_hostname"></a> [cluster\_hostname](#output\_cluster\_hostname) | The hostname of the Redshift cluster |
320320
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | The Redshift cluster ID |
321321
| <a name="output_cluster_identifier"></a> [cluster\_identifier](#output\_cluster\_identifier) | The Redshift cluster identifier |
322+
| <a name="output_cluster_master_password"></a> [cluster\_master\_password](#output\_cluster\_master\_password) | The Redshift cluster master password |
323+
| <a name="output_cluster_master_username"></a> [cluster\_master\_username](#output\_cluster\_master\_username) | The Redshift cluster master username |
322324
| <a name="output_cluster_namespace_arn"></a> [cluster\_namespace\_arn](#output\_cluster\_namespace\_arn) | The namespace Amazon Resource Name (ARN) of the cluster |
323325
| <a name="output_cluster_node_type"></a> [cluster\_node\_type](#output\_cluster\_node\_type) | The type of nodes in the cluster |
324326
| <a name="output_cluster_nodes"></a> [cluster\_nodes](#output\_cluster\_nodes) | The nodes in the cluster. Each node is a map of the following attributes: `node_role`, `private_ip_address`, and `public_ip_address` |

examples/complete/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ No inputs.
7575
| <a name="output_cluster_hostname"></a> [cluster\_hostname](#output\_cluster\_hostname) | The hostname of the Redshift cluster |
7676
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | The Redshift cluster ID |
7777
| <a name="output_cluster_identifier"></a> [cluster\_identifier](#output\_cluster\_identifier) | The Redshift cluster identifier |
78+
| <a name="output_cluster_master_password"></a> [cluster\_master\_password](#output\_cluster\_master\_password) | The Redshift cluster master password |
79+
| <a name="output_cluster_master_username"></a> [cluster\_master\_username](#output\_cluster\_master\_username) | The Redshift cluster master username |
7880
| <a name="output_cluster_namespace_arn"></a> [cluster\_namespace\_arn](#output\_cluster\_namespace\_arn) | The namespace Amazon Resource Name (ARN) of the cluster |
7981
| <a name="output_cluster_node_type"></a> [cluster\_node\_type](#output\_cluster\_node\_type) | The type of nodes in the cluster |
8082
| <a name="output_cluster_nodes"></a> [cluster\_nodes](#output\_cluster\_nodes) | The nodes in the cluster. Each node is a map of the following attributes: `node_role`, `private_ip_address`, and `public_ip_address` |

examples/complete/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ output "cluster_namespace_arn" {
112112
value = module.redshift.cluster_namespace_arn
113113
}
114114

115+
output "cluster_master_password" {
116+
description = "The Redshift cluster master password"
117+
value = module.redshift.cluster_master_password
118+
}
119+
120+
output "cluster_master_username" {
121+
description = "The Redshift cluster master username"
122+
value = module.redshift.cluster_master_username
123+
}
124+
115125
################################################################################
116126
# Parameter Group
117127
################################################################################

main.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
data "aws_partition" "current" {}
1+
data "aws_partition" "current" {
2+
count = var.create && var.create_scheduled_action_iam_role ? 1 : 0
3+
}
4+
5+
locals {
6+
dns_suffix = try(data.aws_partition.current[0].dns_suffix, "")
7+
}
28

39
resource "random_password" "master_password" {
410
count = var.create && var.create_random_password ? 1 : 0
@@ -105,8 +111,9 @@ resource "aws_redshift_parameter_group" "this" {
105111

106112
dynamic "parameter" {
107113
for_each = var.parameter_group_parameters
114+
108115
content {
109-
name = parameter.value.name
116+
name = try(parameter.value.name, parameter.key)
110117
value = parameter.value.value
111118
}
112119
}
@@ -210,7 +217,7 @@ data "aws_iam_policy_document" "scheduled_action_assume" {
210217

211218
principals {
212219
type = "Service"
213-
identifiers = ["scheduler.redshift.${data.aws_partition.current.dns_suffix}"]
220+
identifiers = ["scheduler.redshift.${local.dns_suffix}"]
214221
}
215222
}
216223
}

outputs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ output "cluster_namespace_arn" {
116116
value = try(aws_redshift_cluster.this[0].cluster_namespace_arn, null)
117117
}
118118

119+
output "cluster_master_password" {
120+
description = "The Redshift cluster master password"
121+
value = try(aws_redshift_cluster.this[0].master_password, null)
122+
sensitive = true
123+
}
124+
125+
output "cluster_master_username" {
126+
description = "The Redshift cluster master username"
127+
value = try(aws_redshift_cluster.this[0].master_username, null)
128+
sensitive = true
129+
}
130+
119131
################################################################################
120132
# Parameter Group
121133
################################################################################

wrappers/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "wrapper" {
22
description = "Map of outputs of a wrapper."
33
value = module.wrapper
4-
# sensitive = false # No sensitive module output found
4+
sensitive = true # At least one sensitive module output (cluster_master_password) found (requires Terraform 0.14+)
55
}

0 commit comments

Comments
 (0)