Repository: ansible/ansible-modules-core

Issue:
ec2_asg insisting that subnet id does not exist
#### Issue Type:

Bug Report
#### Ansible Version:

ansible 1.9 installed from source develop branch
#### Environment:

OSX 10.10
#### Summary:

Passing in a subnet in the same way provided in the module examples `['subnet-1234']` returns an AWS API error when the ASG has already been created. 
#### Steps To Reproduce:

Create a playbook similar to the following:

``` yaml

---
- name: debug aws stuff
  hosts: all
  gather_facts: no
  tasks:
    - name: create Auto Scaling Group
      ec2_asg:
        name: "somename"
        launch_config_name: "someconfig"
        aws_access_key: KEY
        aws_secret_key: KEY
        min_size: 1
        max_size: 2
        region: us-east-1
        vpc_zone_identifier: [ 'subnet-1234' ]
        state: present
```
#### Expected Results:

OK
#### Actual Results:

```
failed: [localhost] => {"failed": true}
msg: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
  <Error>
    <Type>Sender</Type>
    <Code>ValidationError</Code>
    <Message>The subnet ID '['subnet-1234']' does not exist</Message>
  </Error>
  <RequestId>7061d8b0-807f-11e4-a663-115fef5ac273</RequestId>
</ErrorResponse>


FATAL: all hosts have already failed -- aborting
```



Discussion:
# Can You Help Us Out?

Thanks for filing a ticket! I am the friendly GitHub Ansibot. 

It looks like you might not have filled out the issue description based on our standard issue template.  You might not have known about that, and that's ok too, we'll tell you how to do it.

We have a standard template because Ansible is a really busy project and it helps to have some standard information in each ticket, and GitHub doesn't yet provide a standard facility to do this like some other bug trackers.  We hope you understand as this is really valuable to us!. 

Solving this is simple: please copy the contents of this [template](https://raw.githubusercontent.com/ansible/ansible/devel/ISSUE_TEMPLATE.md) and **paste it into the description** of your ticket.  That's it!

# If You Had A Question To Ask Instead

If you happened to have a "how do I do this in Ansible" type of question, that's probably more of a user-list question than a bug report, and you should probably ask this question on the project mailing list instead.  

However, if you think you have a bug, the report is the way to go!  We definitely want all the bugs filed :)  Just trying to help!

# About Priority Tags

Since you're here, we'll also share some useful information at this time.

In general tickets will be assigned a priority between P1 (highest) and P5, and then worked in priority order. We may also have some follow up questions along the way, so keeping up with follow up comments via GitHub notifications is a good idea.

Due to large interest in Ansible, humans may not comment on your ticket immediately.  

# Mailing Lists

If you have concerns or questions, you're welcome to stop by the ansible-project or ansible-development mailing lists, as appropriate.  Here are the links:
- https://groups.google.com/forum/#!forum/ansible-project - for discussion of bugs and how-to type questions
- https://groups.google.com/forum/#!forum/ansible-devel - for discussion on how to implement a code change, or feature brainstorming among developers

Thanks again for the interest in Ansible!

With the ansible development version `ansible 1.9 (devel 86202b9fe3)`
`vpc_zone_identifier: subnet-1234, subnet-5678`
 was working.
After updating to the latest (`ansible 1.9 (devel a0ff0f8198)`), neither `vpc_zone_identifier: subnet-1234` works nor `vpc_zone_identifier: [ "subnet-1234" ]`

Now it creates without issue, but doesn't seem to have idempotency atm as it errs out with the same original error if it has already been created.

Experiencing the same issue - creates auto scaling group when executed for the first time but throws error all subsequent runs:

```
TASK: [deploy | AWS | Create auto scaling group] ******************************
failed: [XX.XX.XX.XX -> 127.0.0.1] => {"failed": true}
msg: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
  <Error>
    <Type>Sender</Type>
    <Code>ValidationError</Code>
    <Message>The subnet ID '['...']' does not exist</Message>
  </Error>
  <RequestId>...</RequestId>
</ErrorResponse>
```


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
@@ -326,6 +326,8 @@ def create_autoscaling_group(connection, module):
         for attr in ASG_ATTRIBUTES:
             if module.params.get(attr):
                 module_attr = module.params.get(attr)
+                if attr == 'vpc_zone_identifier':
+                    module_attr = ','.join(module_attr)
                 group_attr = getattr(as_group, attr)
                 # we do this because AWS and the module may return the same list
                 # sorted differently


Test patch: