Repository: ansible/ansible

Issue:
Add support for Timeout (--timeout-in-minutes) parameter in Cloudformation module
##### ISSUE TYPE
 
- Bug Report

##### COMPONENT NAME

Cloudformation module

##### ANSIBLE VERSION
<!--- Paste verbatim output from "ansible --version" between quotes below -->
```
ansible 2.4.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.12 (default, Nov 20 2017, 18:23:56) [GCC 5.4.0 20160609]

```

##### CONFIGURATION

No changes

##### OS / ENVIRONMENT

Ubuntu 16.04

##### SUMMARY

I believe this is a bug, that Ansible Cloudformation module does not support important Timeout parameter (--timeout-in-minutes key in aws-cli 'create-stack' call).

(Documentation:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-add-tags.html )

##### STEPS TO REPRODUCE

Check module documentation

##### EXPECTED RESULTS

Timeout parameter is supported

##### ACTUAL RESULTS

Timeout parameter is not supported


Discussion:
Files identified in the description:
* [lib/ansible/modules/cloud/amazon/cloudformation.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/amazon/cloudformation.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @jsmartin @ryansb @tedder @willthames
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
`needs_contributor`. It's gonna take some work to figure out where this is supported- e.g., I think create supports it, but not update.

Resolving patch:
diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py
--- a/lib/ansible/modules/cloud/amazon/cloudformation.py
+++ b/lib/ansible/modules/cloud/amazon/cloudformation.py
@@ -30,6 +30,12 @@
       - If a stacks fails to form, rollback will remove the stack
     type: bool
     default: 'no'
+  create_timeout:
+    description:
+      - The amount of time (in minutes) that can pass before the stack status becomes CREATE_FAILED
+    required: false
+    default: null
+    version_added: "2.6"
   template_parameters:
     description:
       - A list of hashes of all the template variables for the stack. The value can be a string or a dict.
@@ -207,6 +213,15 @@
     template_url: https://s3.amazonaws.com/my-bucket/cloudformation.template
     termination_protection: yes
 
+# Configure TimeoutInMinutes before the stack status becomes CREATE_FAILED
+# In this case, if disable_rollback is not set or is set to false, the stack will be rolled back.
+- name: enable termination protection during stack creation
+  cloudformation:
+    stack_name: my_stack
+    state: present
+    template_url: https://s3.amazonaws.com/my-bucket/cloudformation.template
+    create_timeout: 5
+
 '''
 
 RETURN = '''
@@ -301,9 +316,11 @@ def create_stack(module, stack_params, cfn):
     if 'TemplateBody' not in stack_params and 'TemplateURL' not in stack_params:
         module.fail_json(msg="Either 'template', 'template_body' or 'template_url' is required when the stack does not exist.")
 
-    # 'disablerollback' and 'EnableTerminationProtection' only
-    # apply on creation, not update.
+    # 'DisableRollback', 'TimeoutInMinutes' and 'EnableTerminationProtection'
+    # only apply on creation, not update.
     stack_params['DisableRollback'] = module.params['disable_rollback']
+    if module.params.get('create_timeout') is not None:
+        stack_params['TimeoutInMinutes'] = module.params['create_timeout']
     if module.params.get('termination_protection') is not None:
         if boto_supports_termination_protection(cfn):
             stack_params['EnableTerminationProtection'] = bool(module.params.get('termination_protection'))
@@ -542,6 +559,7 @@ def main():
         notification_arns=dict(default=None, required=False),
         stack_policy=dict(default=None, required=False),
         disable_rollback=dict(default=False, type='bool'),
+        create_timeout=dict(default=None, type='int'),
         template_url=dict(default=None, required=False),
         template_body=dict(default=None, require=False),
         template_format=dict(default=None, choices=['json', 'yaml'], required=False),


Test patch: