Repository: ansible/ansible-modules-core

Issue:
ec2_asg module fails on Ansible 1.8
##### Issue Type:

Bug Report 
##### Ansible Version:

1.8
##### Environment:

Ubuntu 14.04.1
Ansible Tower 2.0.2
##### Summary:

ec2_asg module fails to run on 1.8 with a regular, 1.7 compatible playbook. 
##### Steps To Reproduce:
- Run the playbook below creating/updating an ASG on 1.7.2 and Tower. Input variables for your asg and launch config. Eg. 

asg_name: auto_asg2
lc_name: sandbox_v1.5.1
- Log into into the machine, download the Git repo for 1.8, get the git submodules (git submodule update --init --recursive) and then make install.
- Re-run the Job Template with the same parameters. It fails:

Sample playbook: 

```

---
- hosts: 127.0.0.1
  connection: local

  tasks:
  - local_action:
      module: ec2_asg
      name: "{{ asg_name }}"
      launch_config_name: "{{ lc_name }}"
      health_check_type: EC2
      region: us-west-1
      min_size: 1
      max_size: 3
      desired_capacity: 2
      vpc_zone_identifier: 'subnet-xxxxx'
      tags:
        - environment: production
          propagate_at_launch: no

```
- Replaced the subnet identifier with a placeholder for security reasons. 
##### Expected Results:

Playbook should create an AWS AutoScaling Group or update it with the provided Launch Configuration, desired capacity, etc. The playbook is based on the documentation and works fine under 1.7. 
##### Actual Results:

```
PLAY [127.0.0.1] **************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [ec2_asg] ***************************************************************
failed: [127.0.0.1 -> 127.0.0.1] => {"failed": true, "parsed": false}
Traceback (most recent call last):
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1414625502.37-190450096943868/ec2_asg", line 2324, in <module>
    main()
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1414625502.37-190450096943868/ec2_asg", line 2314, in main
    create_changed, asg_properties=create_autoscaling_group(connection, module)
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1414625502.37-190450096943868/ec2_asg", line 2054, in create_autoscaling_group
    existing_tag_map = dict((tag.key, tag) for tag in existing_tags)
  File "/var/lib/awx/.ansible/tmp/ansible-tmp-1414625502.37-190450096943868/ec2_asg", line 2054, in <genexpr>
    existing_tag_map = dict((tag.key, tag) for tag in existing_tags)
AttributeError: 'dict' object has no attribute 'key'


FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/var/lib/awx/asg_update.retry

127.0.0.1                  : ok=1    changed=0    unreachable=0    failed=1
```



Discussion:

Resolving patch:
diff --git a/cloud/amazon/ec2_asg.py b/cloud/amazon/ec2_asg.py
--- a/cloud/amazon/ec2_asg.py
+++ b/cloud/amazon/ec2_asg.py
@@ -199,7 +199,7 @@
 ASG_ATTRIBUTES = ('availability_zones', 'default_cooldown', 'desired_capacity',
     'health_check_period', 'health_check_type', 'launch_config_name',
     'load_balancers', 'max_size', 'min_size', 'name', 'placement_group',
-    'tags', 'termination_policies', 'vpc_zone_identifier')
+    'termination_policies', 'vpc_zone_identifier')
 
 INSTANCE_ATTRIBUTES = ('instance_id', 'health_status', 'lifecycle_state', 'launch_config_name')
 


Test patch: