From 5e61f0882b128951947b31ca3ea192465ae539a8 Mon Sep 17 00:00:00 2001 From: whiter Date: Wed, 7 Oct 2015 14:01:47 +1100 Subject: [PATCH] Add region to doc and handle missing region parameter --- cloud/amazon/ec2_metric_alarm.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cloud/amazon/ec2_metric_alarm.py b/cloud/amazon/ec2_metric_alarm.py index cead47460fa..94f303212ae 100644 --- a/cloud/amazon/ec2_metric_alarm.py +++ b/cloud/amazon/ec2_metric_alarm.py @@ -259,7 +259,6 @@ def main(): insufficient_data_actions=dict(type='list'), ok_actions=dict(type='list'), state=dict(default='present', choices=['present', 'absent']), - region=dict(aliases=['aws_region', 'ec2_region']), ) ) @@ -271,10 +270,14 @@ def main(): state = module.params.get('state') region, ec2_url, aws_connect_params = get_aws_connection_info(module) - try: - connection = connect_to_aws(boto.ec2.cloudwatch, region, **aws_connect_params) - except (boto.exception.NoAuthHandlerFound, StandardError), e: - module.fail_json(msg=str(e)) + + if region: + try: + connection = connect_to_aws(boto.ec2.cloudwatch, region, **aws_connect_params) + except (boto.exception.NoAuthHandlerFound, StandardError), e: + module.fail_json(msg=str(e)) + else: + module.fail_json(msg="region must be specified") if state == 'present': create_metric_alarm(connection, module)