If you have an ElastiCache Memcached cluster that you no longer need, it’s better to delete it. Dno’t believe me? Even AWS said so too:
It is almost always a good idea to delete clusters that you are not actively using. Until a cluster’s status is deleted, you continue to incur charges for it. [1]
Well, I have a Memcached cluster that I don’t need anymore. But instead of deleting this cluster using AWS console [1], I’m going to do this via AWS CLI.
The first step is to identify the cache’s cluster to delete by finding its ID. To do that, we can use describe-cache-clusters
[2] to show or list all cluster IDs.
❯ aws elasticache describe-cache-clusters \
--query "CacheClusters[].{CacheClusterId:CacheClusterId}" \
--output table
-----------------------
|DescribeCacheClusters|
+---------------------+
| CacheClusterId |
+---------------------+
| test-enc-cache |
+---------------------+
In my case, I only have 1 cluster, and its ID is test-enc-cache
.
With that ID, we can use another command, delete-cache-cluster
[3] to delete it:
❯ aws elasticache delete-cache-cluster --cache-cluster-id test-enc-cache
{
"CacheCluster": {
"CacheClusterId": "test-enc-cache",
"ConfigurationEndpoint": {
"Address": "test-enc-cache.xxxxxx.cfg.apse2.cache.amazonaws.com",
"Port": 11211
},
"ClientDownloadLandingPage": "https://console.aws.amazon.com/elasticache/home#client-download:",
"CacheNodeType": "cache.t4g.medium",
"Engine": "memcached",
"EngineVersion": "1.6.17",
"CacheClusterStatus": "deleting",
"NumCacheNodes": 1,
"PreferredAvailabilityZone": "ap-southeast-2a",
"CacheClusterCreateTime": "2023-09-29T08:37:10.022000+00:00",
"PreferredMaintenanceWindow": "fri:14:00-fri:15:00",
"PendingModifiedValues": {},
"CacheSecurityGroups": [],
"CacheParameterGroup": {
"CacheParameterGroupName": "default.memcached1.6",
"ParameterApplyStatus": "in-sync",
"CacheNodeIdsToReboot": []
},
"CacheSubnetGroupName": "web-demo",
"AutoMinorVersionUpgrade": true,
"SecurityGroups": [
{
"SecurityGroupId": "sg-11111111111111111",
"Status": "active"
}
],
"TransitEncryptionEnabled": true,
"AtRestEncryptionEnabled": false,
"ARN": "arn:aws:elasticache:ap-southeast-2:444444444444:cluster:test-enc-cache",
"ReplicationGroupLogDeliveryEnabled": false,
"LogDeliveryConfigurations": [],
"NetworkType": "ipv4",
"IpDiscovery": "ipv4"
}
}
The output is pretty verbose, but what we need to pay attention is:
"CacheClusterStatus": "deleting",
It’s normal to take more than a few minutes to delete a cluster. Sometimes it could take even longer depending on your cluster’s size and configuration.
To confirm if the cluster has been deleted, we can run the command:
❯ aws elasticache describe-cache-clusters --cache-cluster-id test-enc-cache
An error occurred (CacheClusterNotFound) when calling the DescribeCacheClusters operation: CacheCluster not found: test-enc-cache
References: