We have a clustered Redis setup (engine version 5.04) with three node groups each in their own AZ, each group contains three nodes, encryption is enabled in transit and at rest. Stunnel is configured on a bastion host, which allows me to run a bash script to flush each of the primary replicas when required (during upgrades to our application).
After applying the latest Redis software patches via the console, the primary endpoint in each node group has changed due to automatic failover and I'm looking for the best way to determine the new primary endpoints so my bash script can be updated accordingly.
The documentation states that running aws elasticache describe-replication-groups --replication-group-id my-replication-group should indicate the CurrentRole of the node group members e.g.
"NodeGroupMembers": [
{
"CurrentRole": "primary",
"PreferredAvailabilityZone": "us-west-2a",
"CacheNodeId": "0001",
"ReadEndpoint": {
"Port": 6379,
"Address": "myreplgroup-001.1abc4d.0001.usw2.cache.amazonaws.com"
},
"CacheClusterId": "myreplgroup-001"
},
{
"CurrentRole": "replica",
"PreferredAvailabilityZone": "us-west-2b",
"CacheNodeId": "0001",
"ReadEndpoint": {
"Port": 6379,
"Address": "myreplgroup-002.1abc4d.0001.usw2.cache.amazonaws.com"
},
"CacheClusterId": "myreplgroup-002"
},
{
...
}
]
My response from this command doesn't contain CurrentRole at all:
"NodeGroupMembers": [
{
"PreferredAvailabilityZone": "ap-southeast-2c",
"CacheNodeId": "0001",
"CacheClusterId": "my-replication-group-0001-001"
},
{
"PreferredAvailabilityZone": "ap-southeast-2b",
"CacheNodeId": "0001",
"CacheClusterId": "my-replication-group-0001-002"
},
{
"PreferredAvailabilityZone": "ap-southeast-2a",
"CacheNodeId": "0001",
"CacheClusterId": "my-replication-group-0001-003"
}
]
Is there an alternative aws cli command that can be used to determine the primary endpoint? It's easy enough to failover the primary node via the console, but as I can't identify which node is the current primary via console/cli it means guessing which nodes need to be targeted in my flushing script.