Commit b5ae7610 by Petr Svoboda

Add support for tags parameter to cloudformation module

Expose boto.cloudformation.create_stack() tags parameter. Supplied tags
will be applied to stack and all it's resources on stack creation.
Cannot be updated later (not supported by UpdateStack CloudFormation
API).
parent 0ee236bf
...@@ -60,6 +60,12 @@ options: ...@@ -60,6 +60,12 @@ options:
required: true required: true
default: null default: null
aliases: [] aliases: []
tags:
description:
- Dictionary of tags to associate with stack and it's resources during stack creation. Cannot be updated later.
required: false
default: null
aliases: []
requirements: [ "boto" ] requirements: [ "boto" ]
author: James S. Martin author: James S. Martin
...@@ -79,6 +85,8 @@ tasks: ...@@ -79,6 +85,8 @@ tasks:
DiskType: ephemeral DiskType: ephemeral
InstanceType: m1.small InstanceType: m1.small
ClusterSize: 3 ClusterSize: 3
tags:
Stack: ansible-cloudformation
''' '''
import json import json
...@@ -163,7 +171,8 @@ def main(): ...@@ -163,7 +171,8 @@ def main():
region=dict(aliases=['aws_region', 'ec2_region'], required=True, choices=AWS_REGIONS), region=dict(aliases=['aws_region', 'ec2_region'], required=True, choices=AWS_REGIONS),
state=dict(default='present', choices=['present', 'absent']), state=dict(default='present', choices=['present', 'absent']),
template=dict(default=None, required=True), template=dict(default=None, required=True),
disable_rollback=dict(default=False) disable_rollback=dict(default=False),
tags=dict(default=None)
) )
) )
...@@ -173,6 +182,7 @@ def main(): ...@@ -173,6 +182,7 @@ def main():
template_body = open(module.params['template'], 'r').read() template_body = open(module.params['template'], 'r').read()
disable_rollback = module.params['disable_rollback'] disable_rollback = module.params['disable_rollback']
template_parameters = module.params['template_parameters'] template_parameters = module.params['template_parameters']
tags = module.params['tags']
if not r: if not r:
if 'AWS_REGION' in os.environ: if 'AWS_REGION' in os.environ:
...@@ -203,7 +213,8 @@ def main(): ...@@ -203,7 +213,8 @@ def main():
cfn.create_stack(stack_name, parameters=template_parameters_tup, cfn.create_stack(stack_name, parameters=template_parameters_tup,
template_body=template_body, template_body=template_body,
disable_rollback=disable_rollback, disable_rollback=disable_rollback,
capabilities=['CAPABILITY_IAM']) capabilities=['CAPABILITY_IAM'],
tags=tags)
operation = 'CREATE' operation = 'CREATE'
except Exception, err: except Exception, err:
error_msg = boto_exception(err) error_msg = boto_exception(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment