From 6f66e88bd856857160a9f86e69df457ace683d75 Mon Sep 17 00:00:00 2001 From: kwerey Date: Tue, 16 May 2017 16:09:54 +0100 Subject: [PATCH] [cloud] Use boto connect_to_region so Elasticache works in AWS China (#24250) --- lib/ansible/modules/cloud/amazon/elasticache.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/elasticache.py b/lib/ansible/modules/cloud/amazon/elasticache.py index aebb007b8e7..bc666c287a5 100644 --- a/lib/ansible/modules/cloud/amazon/elasticache.py +++ b/lib/ansible/modules/cloud/amazon/elasticache.py @@ -146,8 +146,7 @@ import time try: import boto - from boto.elasticache.layer1 import ElastiCacheConnection - from boto.regioninfo import RegionInfo + from boto.elasticache import connect_to_region HAS_BOTO = True except ImportError: HAS_BOTO = False @@ -430,10 +429,8 @@ class ElastiCacheManager(object): def _get_elasticache_connection(self): """Get an elasticache connection""" try: - endpoint = "elasticache.%s.amazonaws.com" % self.region - connect_region = RegionInfo(name=self.region, endpoint=endpoint) - return ElastiCacheConnection( - region=connect_region, + return connect_to_region( + region_name=self.region, **self.aws_connect_kwargs ) except boto.exception.NoAuthHandlerFound as e: