el n00b
el n00b

Reputation: 1853

Get endpoint for Terraform with aws_elasticache_replication_group

I have what I think is a simple Terraform config for AWS ElastiCache with Redis:

resource "aws_elasticache_replication_group" "my_replication_group" {
  replication_group_id          = "my-rep-group",
  replication_group_description = "eln00b"

  node_type                     = "cache.m4.large"
  port                          = 6379
  parameter_group_name          = "default.redis5.0.cluster.on"

  snapshot_retention_limit      = 1
  snapshot_window               = "00:00-05:00"

  subnet_group_name             = "${aws_elasticache_subnet_group.my_subnet_group.name}"

  automatic_failover_enabled    = true

  cluster_mode {
    num_node_groups             = 1
    replicas_per_node_group     = 1
  }
}

I tried to define the endpoint output using:

output "my_cache" {
  value = "${aws_elasticache_replication_group.my_replication_group.primary_endpoint_address}"
}

When I run an apply through terragrunt I get:

Error: Error running plan: 1 error(s) occurred:

module.mod.output.my_cache: Resource 'aws_elasticache_replication_group.my_replication_group' does not have attribute 'primary_endpoint_address' for variable 'aws_elasticache_replication_group.my_replication_group.primary_endpoint_address'

What am I doing wrong here?

Upvotes: 6

Views: 7066

Answers (1)

ydaetskcoR
ydaetskcoR

Reputation: 56839

The primary_endpoint_address attribute is only available for non cluster-mode Redis replication groups as mentioned in the docs:

primary_endpoint_address - (Redis only) The address of the endpoint for the primary node in the replication group, if the cluster mode is disabled.

When using cluster mode you should use configuration_endpoint_address instead to connect to the Redis cluster.

Upvotes: 6

Related Questions