문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top