Merge pull request #2421 from willthames/ec2_fix_vpc_security_token
Use connect_to_aws where possible
This commit is contained in:
commit
1c4da434c7
9 changed files with 10 additions and 15 deletions
|
@ -302,10 +302,7 @@ def main():
|
||||||
stack_outputs = {}
|
stack_outputs = {}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cfn = boto.cloudformation.connect_to_region(
|
cfn = connect_to_aws(boto.cloudformation, region, **aws_connect_kwargs)
|
||||||
region,
|
|
||||||
**aws_connect_kwargs
|
|
||||||
)
|
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
update = False
|
update = False
|
||||||
|
|
|
@ -1390,7 +1390,7 @@ def main():
|
||||||
|
|
||||||
if region:
|
if region:
|
||||||
try:
|
try:
|
||||||
vpc = boto.vpc.connect_to_region(region, **aws_connect_kwargs)
|
vpc = connect_to_aws(boto.vpc, region, **aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
module.fail_json(msg = str(e))
|
module.fail_json(msg = str(e))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -720,10 +720,7 @@ def main():
|
||||||
# If we have a region specified, connect to its endpoint.
|
# If we have a region specified, connect to its endpoint.
|
||||||
if region:
|
if region:
|
||||||
try:
|
try:
|
||||||
vpc_conn = boto.vpc.connect_to_region(
|
vpc_conn = connect_to_aws(boto.vpc, region, **aws_connect_kwargs)
|
||||||
region,
|
|
||||||
**aws_connect_kwargs
|
|
||||||
)
|
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
module.fail_json(msg = str(e))
|
module.fail_json(msg = str(e))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -576,7 +576,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if region:
|
if region:
|
||||||
iam = boto.iam.connect_to_region(region, **aws_connect_kwargs)
|
iam = connect_to_aws(boto.iam, region, **aws_connect_kwargs)
|
||||||
else:
|
else:
|
||||||
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
|
|
|
@ -248,7 +248,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if region:
|
if region:
|
||||||
iam = boto.iam.connect_to_region(region, **aws_connect_kwargs)
|
iam = connect_to_aws(boto.iam, region, **aws_connect_kwargs)
|
||||||
else:
|
else:
|
||||||
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
|
|
|
@ -315,7 +315,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if region:
|
if region:
|
||||||
iam = boto.iam.connect_to_region(region, **aws_connect_kwargs)
|
iam = connect_to_aws(boto.iam, region, **aws_connect_kwargs)
|
||||||
else:
|
else:
|
||||||
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
iam = boto.iam.connection.IAMConnection(**aws_connect_kwargs)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
|
|
|
@ -247,7 +247,7 @@ def main():
|
||||||
module.fail_json(msg = str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set."))
|
module.fail_json(msg = str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = boto.rds.connect_to_region(region, **aws_connect_kwargs)
|
conn = connect_to_aws(boto.rds, region, **aws_connect_kwargs)
|
||||||
except boto.exception.BotoServerError, e:
|
except boto.exception.BotoServerError, e:
|
||||||
module.fail_json(msg = e.error_message)
|
module.fail_json(msg = e.error_message)
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ def main():
|
||||||
module.fail_json(msg = str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set."))
|
module.fail_json(msg = str("Either region or AWS_REGION or EC2_REGION environment variable or boto config aws_region or ec2_region must be set."))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = boto.rds.connect_to_region(region, **aws_connect_kwargs)
|
conn = connect_to_aws(boto.rds, region, **aws_connect_kwargs)
|
||||||
except boto.exception.BotoServerError, e:
|
except boto.exception.BotoServerError, e:
|
||||||
module.fail_json(msg = e.error_message)
|
module.fail_json(msg = e.error_message)
|
||||||
|
|
||||||
|
|
|
@ -459,7 +459,8 @@ def main():
|
||||||
walrus = urlparse.urlparse(s3_url).hostname
|
walrus = urlparse.urlparse(s3_url).hostname
|
||||||
s3 = boto.connect_walrus(walrus, **aws_connect_kwargs)
|
s3 = boto.connect_walrus(walrus, **aws_connect_kwargs)
|
||||||
else:
|
else:
|
||||||
s3 = boto.s3.connect_to_region(location, is_secure=True, **aws_connect_kwargs)
|
aws_connect_args['is_secure'] = True
|
||||||
|
s3 = connect_to_aws(boto.s3, location, **aws_connect_args)
|
||||||
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
|
# use this as fallback because connect_to_region seems to fail in boto + non 'classic' aws accounts in some cases
|
||||||
if s3 is None:
|
if s3 is None:
|
||||||
s3 = boto.connect_s3(**aws_connect_kwargs)
|
s3 = boto.connect_s3(**aws_connect_kwargs)
|
||||||
|
|
Loading…
Reference in a new issue