Add cache_subnet_group to elasticache module

According to the [docs] cache subnet groups are required inside a VPC.

[docs]: http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/CacheSubnetGroups.html
This commit is contained in:
Brandon W Maister 2014-10-06 10:49:22 -04:00
parent 0771dd12ca
commit 3cb2346312

View file

@ -58,6 +58,12 @@ options:
- The port number on which each of the cache nodes will accept connections
required: false
default: 11211
cache_subnet_group:
description:
- The subnet group name to associate with. Only use if inside a vpc. Required if inside a vpc
required: conditional
default: None
version_added: "1.7"
security_group_ids:
description:
- A list of vpc security group names to associate with this cache cluster. Only use if inside a vpc
@ -66,7 +72,7 @@ options:
version_added: "1.6"
cache_security_groups:
description:
- A list of cache security group names to associate with this cache cluster
- A list of cache security group names to associate with this cache cluster. Must be an empty list if inside a vpc
required: false
default: ['default']
zone:
@ -155,7 +161,8 @@ class ElastiCacheManager(object):
EXIST_STATUSES = ['available', 'creating', 'rebooting', 'modifying']
def __init__(self, module, name, engine, cache_engine_version, node_type,
num_nodes, cache_port, cache_security_groups, security_group_ids, zone, wait,
num_nodes, cache_port, cache_subnet_group,
cache_security_groups, security_group_ids, zone, wait,
hard_modify, aws_access_key, aws_secret_key, region):
self.module = module
self.name = name
@ -164,6 +171,7 @@ class ElastiCacheManager(object):
self.node_type = node_type
self.num_nodes = num_nodes
self.cache_port = cache_port
self.cache_subnet_group = cache_subnet_group
self.cache_security_groups = cache_security_groups
self.security_group_ids = security_group_ids
self.zone = zone
@ -222,6 +230,7 @@ class ElastiCacheManager(object):
engine_version=self.cache_engine_version,
cache_security_group_names=self.cache_security_groups,
security_group_ids=self.security_group_ids,
cache_subnet_group_name=self.cache_subnet_group,
preferred_availability_zone=self.zone,
port=self.cache_port)
except boto.exception.BotoServerError, e:
@ -484,6 +493,7 @@ def main():
node_type={'required': False, 'default': 'cache.m1.small'},
num_nodes={'required': False, 'default': None, 'type': 'int'},
cache_port={'required': False, 'default': 11211, 'type': 'int'},
cache_subnet_group={'required': False, 'default': None},
cache_security_groups={'required': False, 'default': ['default'],
'type': 'list'},
security_group_ids={'required': False, 'default': [],
@ -507,6 +517,7 @@ def main():
node_type = module.params['node_type']
num_nodes = module.params['num_nodes']
cache_port = module.params['cache_port']
cache_subnet_group = module.params['cache_subnet_group']
cache_security_groups = module.params['cache_security_groups']
security_group_ids = module.params['security_group_ids']
zone = module.params['zone']
@ -522,6 +533,7 @@ def main():
elasticache_manager = ElastiCacheManager(module, name, engine,
cache_engine_version, node_type,
num_nodes, cache_port,
cache_subnet_group,
cache_security_groups,
security_group_ids, zone, wait,
hard_modify, aws_access_key,