mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
Add some failure handling for region and publish
This commit is contained in:
@@ -149,6 +149,8 @@ def main():
|
|||||||
https = module.params['https']
|
https = module.params['https']
|
||||||
|
|
||||||
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
|
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
|
||||||
|
if not region:
|
||||||
|
module.fail_json(msg="region must be specified")
|
||||||
try:
|
try:
|
||||||
connection = connect_to_aws(boto.sns, region, **aws_connect_params)
|
connection = connect_to_aws(boto.sns, region, **aws_connect_params)
|
||||||
except boto.exception.NoAuthHandlerFound, e:
|
except boto.exception.NoAuthHandlerFound, e:
|
||||||
@@ -177,8 +179,11 @@ def main():
|
|||||||
dict_msg.update(https=https)
|
dict_msg.update(https=https)
|
||||||
|
|
||||||
json_msg = json.dumps(dict_msg)
|
json_msg = json.dumps(dict_msg)
|
||||||
connection.publish(topic=arn_topic, subject=subject,
|
try:
|
||||||
message_structure='json', message=json_msg)
|
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")
|
module.exit_json(msg="OK")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user