Skip to content

Commit 9ff84a5

Browse files
committed
fix the output and change the logic on parameter group creation
1 parent 2a3115b commit 9ff84a5

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Diff for: examples/main.tf

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ module "redis" {
2929
subnet_group_name = "default"
3030
elasticache_parameter_group_family = "redis5.0"
3131

32+
parameter_group_name = "just_a_group_name"
33+
3234
cluster_size = 1
3335

3436
apply_immediately = true

Diff for: main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ locals {
33
}
44

55
resource "aws_elasticache_parameter_group" "this" {
6-
count = var.enabled ? 1 : 0
6+
count = var.enabled && var.parameter_group_name == "" || var.parameter_group_name == null ? 1 : 0
77

88
name = var.name
99
family = var.elasticache_parameter_group_family

Diff for: outputs.tf

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
output "endpoint" {
22
description = "Redis primary or configuration endpoint, whichever is appropriate for the given cluster mode"
3-
value = aws_elasticache_replication_group.this[0].primary_endpoint_address
3+
value = try(aws_elasticache_replication_group.this[0].primary_endpoint_address, null)
44
}
55

66
output "reader_endpoint_address" {
77
description = "The address of the endpoint for the reader node in the replication group, if the cluster mode is disabled"
8-
value = aws_elasticache_replication_group.this[0].reader_endpoint_address
8+
value = try(aws_elasticache_replication_group.this[0].reader_endpoint_address, null)
99
}
1010

1111
output "member_clusters" {
1212
description = "Redis cluster members"
13-
value = aws_elasticache_replication_group.this[0].member_clusters
13+
value = try(aws_elasticache_replication_group.this[0].member_clusters, null)
1414
}
1515

1616
output "arn" {
1717
description = "Elasticache Replication Group ARN"
18-
value = aws_elasticache_replication_group.this[0].arn
18+
value = try(aws_elasticache_replication_group.this[0].arn, null)
1919
}
2020

2121
output "cluster_enabled" {
2222
description = "Indicates if cluster mode is enabled."
23-
value = aws_elasticache_replication_group.this[0].cluster_enabled
23+
value = try(aws_elasticache_replication_group.this[0].cluster_enabled, null)
2424
}
2525

2626
output "id" {
2727
description = "ID of the ElastiCache Replication Group."
28-
value = aws_elasticache_replication_group.this[0].id
28+
value = try(aws_elasticache_replication_group.this[0].id, null)
2929
}
3030

3131
output "configuration_endpoint_address" {
3232
description = "Address of the replication group configuration endpoint when cluster mode is enabled."
33-
value = aws_elasticache_replication_group.this[0].configuration_endpoint_address
33+
value = try(aws_elasticache_replication_group.this[0].configuration_endpoint_address, null)
3434
}
3535

3636
output "engine_version_actual" {
3737
description = "Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine."
38-
value = aws_elasticache_replication_group.this[0].engine_version_actual
38+
value = try(aws_elasticache_replication_group.this[0].engine_version_actual, null)
3939
}
4040

4141
output "subnet_group_name" {
@@ -50,10 +50,10 @@ output "subnet_group_subnet_ids" {
5050

5151
output "parameter_group_arn" {
5252
description = "The AWS ARN associated with the parameter group."
53-
value = aws_elasticache_parameter_group.this[0].arn
53+
value = try(aws_elasticache_parameter_group.this[0].arn, null)
5454
}
5555

5656
output "parameter_group_id" {
5757
description = "The ElastiCache parameter group name."
58-
value = aws_elasticache_parameter_group.this[0].id
58+
value = try(aws_elasticache_parameter_group.this[0].id, null)
5959
}

0 commit comments

Comments
 (0)