Reputation: 1445
I have a Redis cluster in AWS ElastiCache
resource "aws_elasticache_replication_group" "custom-redis-cluster" {
...
}
I want to access the IP of all of it' clusters.
I have tried using dns_a_record_set
to manually get the IP address from the DNS name
but it's not working as well.
data "dns_a_record_set" "esg-redis-data" {
host = "custom-redis-cluster.abcd1e.clustercfg.use2.cache.amazonaws.com"
}
variable "custom-redis-cluster-addrs" {
type = list(string)
value = data.dns_a_record_set.custom-redis-cluster.addrs
}
Error
Error: Unsupported argument
on endpoint.services.tf line 37, in variable "custom-redis-cluster-addrs":
37: value = data.dns_a_record_set.custom-redis-cluster.addrs
How should I fetch the IP address of all the Redis clusters from Terraform?
Is there a way to fetch the Redis clusters DNS name dynamically instead of hard coding?
Upvotes: 1
Views: 1628
Reputation: 238051
You can't use variables to define custom-redis-cluster-addrs
variable.
But you can create a local
:
locals {
custom-redis-cluster-addrs = data.dns_a_record_set.custom-redis-cluster.addrs
}
and use it as local.custom-redis-cluster-addrs
where you need it.
Upvotes: 2