summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2015-03-03 08:51:35 -0500
committerBrian Coca <bcoca@ansible.com>2015-03-03 08:51:35 -0500
commit72b49f4c71bf956248263eff9f3f762e4fa08642 (patch)
treef6b07fad2304a204033cd9066f7eaabd692b6a7c
parent618806aeeb2f4bc7717f3d0e432ff6ebf1a2ba47 (diff)
parent5e7605475db7e4b2eb838d19a7f3a7e55d5bb8c9 (diff)
downloadansible-modules-core-72b49f4c71bf956248263eff9f3f762e4fa08642.tar.gz
Merge pull request #846 from mlaccetti/devel
Change s3 to use connect_to_region
-rw-r--r--cloud/amazon/s3.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/cloud/amazon/s3.py b/cloud/amazon/s3.py
index 7b914dd9..1b2921a5 100644
--- a/cloud/amazon/s3.py
+++ b/cloud/amazon/s3.py
@@ -125,6 +125,8 @@ import os
import urlparse
import hashlib
+from boto.s3.connection import OrdinaryCallingFormat
+
try:
import boto
from boto.s3.connection import Location
@@ -321,7 +323,6 @@ def main():
if is_fakes3(s3_url):
try:
fakes3 = urlparse.urlparse(s3_url)
- from boto.s3.connection import OrdinaryCallingFormat
s3 = boto.connect_s3(
aws_access_key,
aws_secret_key,
@@ -339,20 +340,20 @@ def main():
module.fail_json(msg = str(e))
else:
try:
- s3 = boto.connect_s3(aws_access_key, aws_secret_key)
+ s3 = boto.s3.connect_to_region(location, aws_access_key_id=aws_access_key, aws_secret_access_key=aws_secret_key, is_secure=True, calling_format=OrdinaryCallingFormat())
except boto.exception.NoAuthHandlerFound, e:
module.fail_json(msg = str(e))
-
+
# If our mode is a GET operation (download), go through the procedure as appropriate ...
if mode == 'get':
-
+
# First, we check to see if the bucket exists, we get "bucket" returned.
bucketrtn = bucket_check(module, s3, bucket)
if bucketrtn is False:
module.fail_json(msg="Target bucket cannot be found", failed=True)
# Next, we check to see if the key in the bucket exists. If it exists, it also returns key_matches md5sum check.
- keyrtn = key_check(module, s3, bucket, obj)
+ keyrtn = key_check(module, s3, bucket, obj)
if keyrtn is False:
module.fail_json(msg="Target key cannot be found", failed=True)