Merge pull request #654 from loia/feature/aws_dynamodb

dynamodb_table docfixes and error handling
This commit is contained in:
Greg DeKoenigsberg 2015-06-29 11:09:07 -04:00
commit 9de82d186a

View file

@ -22,6 +22,7 @@ description:
- Create or delete AWS Dynamo DB tables.
- Can update the provisioned throughput on existing tables.
- Returns the status of the specified table.
version_added: "2.0"
author: Alan Loi (@loia)
version_added: "2.0"
requirements:
@ -42,6 +43,7 @@ options:
- Name of the hash key.
- Required when C(state=present).
required: false
default: null
hash_key_type:
description:
- Type of the hash key.
@ -52,6 +54,7 @@ options:
description:
- Name of the range key.
required: false
default: null
range_key_type:
description:
- Type of the range key.
@ -117,7 +120,7 @@ try:
from boto.dynamodb2.table import Table
from boto.dynamodb2.fields import HashKey, RangeKey
from boto.dynamodb2.types import STRING, NUMBER, BINARY
from boto.exception import BotoServerError, JSONResponseError
from boto.exception import BotoServerError, NoAuthHandlerFound, JSONResponseError
HAS_BOTO = True
except ImportError:
@ -259,7 +262,14 @@ def main():
module.fail_json(msg='boto required for this module')
region, ec2_url, aws_connect_params = get_aws_connection_info(module)
connection = connect_to_aws(boto.dynamodb2, region, **aws_connect_params)
if not region:
module.fail_json(msg='region must be specified')
try:
connection = connect_to_aws(boto.dynamodb2, region, **aws_connect_params)
except (NoAuthHandlerFound, StandardError), e:
module.fail_json(msg=str(e))
state = module.params.get('state')
if state == 'present':
@ -272,4 +282,5 @@ def main():
from ansible.module_utils.basic import *
from ansible.module_utils.ec2 import *
main()
if __name__ == '__main__':
main()