From c8a810df78e2fb72985410dd9eec95c1c73e498b Mon Sep 17 00:00:00 2001 From: "Michael J. Schultz" Date: Fri, 28 Mar 2014 11:08:50 -0500 Subject: [PATCH] Add some failure handling for `region` and `publish` --- library/notification/sns | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/notification/sns b/library/notification/sns index 405759f9f2..f2ed178554 100644 --- a/library/notification/sns +++ b/library/notification/sns @@ -149,6 +149,8 @@ def main(): https = module.params['https'] region, ec2_url, aws_connect_params = get_aws_connection_info(module) + if not region: + module.fail_json(msg="region must be specified") try: connection = connect_to_aws(boto.sns, region, **aws_connect_params) except boto.exception.NoAuthHandlerFound, e: @@ -177,8 +179,11 @@ def main(): dict_msg.update(https=https) json_msg = json.dumps(dict_msg) - connection.publish(topic=arn_topic, subject=subject, - message_structure='json', message=json_msg) + try: + connection.publish(topic=arn_topic, subject=subject, + message_structure='json', message=json_msg) + except boto.exception.BotoServerError, e: + module.fail_json(msg=str(e)) module.exit_json(msg="OK")