Frage

I'm trying to describe my cache cluster nodes in AWS Elasticache. I am using the example from Finding AWS ElastiCache endpoints with Java (the solution code).

I use the code:

 DescribeCacheClustersRequest dccRequest = new DescribeCacheClustersRequest();    
    dccRequest.setShowCacheNodeInfo(true);

    elasticache.setEndpoint("ec2.us-west-1.amazonaws.com");
    DescribeCacheClustersResult clusterResult = elasticache.describeCacheClusters(dccRequest);
    System.out.println("cache cluster node fleet size: " + clusterResult.getCacheClusters().size());
    for (CacheCluster cacheCluster : clusterResult.getCacheClusters()) {
        List<CacheNode> cacheNodes = cacheCluster.getCacheNodes();

        System.out.println("cache cluster size: " + cacheNodes.size());
    }

When I run this code I get the error:

Exception in thread "main" Status Code: 400, AWS Service: AmazonElastiCache, AWS Request ID: null, AWS Error Code: null, AWS Error Message: null

If I remove the setEndpoint code, the code doesn't error out, but no nodes are returned and printed. The reason I am guessing is because the US-EAST region is queried by default.

Does anyone know how I can circumvent this error?

War es hilfreich?

Lösung

Your problem is that you are setting the endpoint to the EC2 endpoint not the Amazon ElastiCache endpoint. The corrected code snippet is:

elasticache.setEndpoint("elasticache.us-west-1.amazonaws.com");

You can find a complete list of endpoints in this document

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top