Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Support CloudFormation YAML native API, backport of 23da0fc
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansb committed Oct 21, 2016
1 parent 410ac59 commit c7210e9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions cloud/amazon/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
version_added: "2.0"
template_format:
description:
- For local templates, allows specification of json or yaml format
default: json
- (deprecated) For local templates, allows specification of json or yaml format. Templates are now passed raw to CloudFormation regardless of format. This parameter is ignored since Ansible 2.2.
default: None
choices: [ json, yaml ]
required: false
version_added: "2.0"
Expand Down Expand Up @@ -147,7 +147,6 @@

import json
import time
import yaml

try:
import boto
Expand Down Expand Up @@ -246,7 +245,7 @@ def main():
stack_policy=dict(default=None, required=False),
disable_rollback=dict(default=False, type='bool'),
template_url=dict(default=None, required=False),
template_format=dict(default='json', choices=['json', 'yaml'], required=False),
template_format=dict(default=None, choices=['json', 'yaml'], required=False),
tags=dict(default=None, type='dict')
)
)
Expand All @@ -270,12 +269,6 @@ def main():
else:
template_body = None

if module.params['template_format'] == 'yaml':
if template_body is None:
module.fail_json(msg='yaml format only supported for local templates')
else:
template_body = json.dumps(yaml.load(template_body), indent=2)

notification_arns = module.params['notification_arns']

if module.params['stack_policy'] is not None:
Expand Down Expand Up @@ -392,6 +385,11 @@ def main():
cfn.delete_stack(stack_name)
result = stack_operation(cfn, stack_name, operation)

if module.params['template_format'] is not None:
result['warnings'] = [('Argument `template_format` is deprecated '
'since Ansible 2.2, JSON and YAML templates are now passed '
'directly to the CloudFormation API.')]

module.exit_json(**result)

# import module snippets
Expand Down

0 comments on commit c7210e9

Please sign in to comment.