Repository: getmoto/moto

Issue:
Redshift create_cluster_subnet_group fails
Here's the code:
```
from moto import mock_redshift, mock_ec2  # moto==1.0.1  - pip installed
from boto3.session import Session         # boto3==1.3.0 - pip installed

@mock_ec2
@mock_redshift
def test_add_redshift_cluster_subnet_group():
    ec2_client = Session().client('ec2')
    vpc = ec2_client.create_vpc(CidrBlock='10.0.0.0/24')
    subnet = ec2_client.create_subnet(CidrBlock='10.0.0.0./24',
                                      VpcId=vpc['Vpc']['VpcId'])
    redshift_client = Session().client('redshift')
    redshift_client.create_cluster_subnet_group(
        ClusterSubnetGroupName='TEST_SUBNET_GROUP',
        Description='test subnet group',
        SubnetIds=[subnet['Subnet']['SubnetId']]
    )
    response = redshift_client.describe_cluster_subnet_groups()
    subnet_group = response['ClusterSubnetGroups'][0]
    assert (subnet_group['ClusterSubnetGroupName'] == 'TEST_SUBNET_GROUP')

if __name__ == '__main__':
    test_add_redshift_cluster_subnet_group()
```
Here's the exception traceback:
```
Traceback (most recent call last):
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/tests/moto_bug.py", line 23, in <module>
    test_add_redshift_cluster_subnet_group()
  File "/Users/bpandola/PyCharmProjects/moto/moto/core/models.py", line 70, in wrapper
    result = func(*args, **kwargs)
  File "/Users/bpandola/PyCharmProjects/moto/moto/core/models.py", line 70, in wrapper
    result = func(*args, **kwargs)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/tests/moto_bug.py", line 16, in test_add_redshift_cluster_subnet_group
    SubnetIds=[subnet['Subnet']['SubnetId']]
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/client.py", line 159, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/client.py", line 483, in _make_api_call
    operation_model, request_dict)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/endpoint.py", line 117, in make_request
    return self._send_request(request_dict, operation_model)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/endpoint.py", line 144, in _send_request
    request, operation_model, attempts)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/endpoint.py", line 209, in _get_response
    response_dict, operation_model.output_shape)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/parsers.py", line 209, in parse
    parsed = self._do_error_parse(response, shape)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/parsers.py", line 435, in _do_error_parse
    root = self._parse_xml_string_to_dom(xml_contents)
  File "/Users/bpandola/PyCharmProjects/redshift-service-broker/env/lib/python2.7/site-packages/botocore/parsers.py", line 387, in _parse_xml_string_to_dom
    "invalid XML received:\n%s" % (e, xml_string))
botocore.parsers.ResponseParserError: Unable to parse response (not well-formed (invalid token): line 1, column 0), invalid XML received:
{"RequestId": "6876f774-7273-11e4-85dc-39e55ca848d1", "Error": {"Message": "Subnet [] not found.", "Code": "InvalidSubnet", "Type": "Sender"}}
```
I was able to track the error down to the `RedshiftResponse.create_cluster_subnet_group()` 
 method in `moto/moto/redshift/responses.py`.  Changing the following line:
```
subnet_ids = self._get_multi_param('SubnetIds.member')
```
to:
```
subnet_ids = self._get_multi_param('SubnetIds.SubnetIdentifier')
```
resolves the issue, but I'm worried it might break something else.  I'm happy to take a stab at a PR if someone more familiar with the codebase can give me some guidance.  It seems this issue might be a `boto` vs `boto3` or `mock_redshift` vs `mock_redshift_deprecated` thing that I don't fully understand.

Thanks in advance for any assistance you can provide.  Love the work you all have done here!


Discussion:

Resolving patch:
diff --git a/moto/redshift/responses.py b/moto/redshift/responses.py
--- a/moto/redshift/responses.py
+++ b/moto/redshift/responses.py
@@ -122,6 +122,10 @@ def create_cluster_subnet_group(self):
         cluster_subnet_group_name = self._get_param('ClusterSubnetGroupName')
         description = self._get_param('Description')
         subnet_ids = self._get_multi_param('SubnetIds.member')
+        # There's a bug in boto3 where the subnet ids are not passed
+        # according to the AWS documentation
+        if not subnet_ids:
+            subnet_ids = self._get_multi_param('SubnetIds.SubnetIdentifier')
 
         subnet_group = self.redshift_backend.create_cluster_subnet_group(
             cluster_subnet_group_name=cluster_subnet_group_name,


Test patch:
diff --git a/tests/test_redshift/test_redshift.py b/tests/test_redshift/test_redshift.py
--- a/tests/test_redshift/test_redshift.py
+++ b/tests/test_redshift/test_redshift.py
@@ -11,7 +11,10 @@
 )
 import sure  # noqa
 
-from moto import mock_ec2_deprecated, mock_redshift_deprecated, mock_redshift
+from moto import mock_ec2
+from moto import mock_ec2_deprecated
+from moto import mock_redshift
+from moto import mock_redshift_deprecated
 
 
 @mock_redshift
@@ -153,6 +156,32 @@ def test_create_cluster_in_subnet_group():
     cluster['ClusterSubnetGroupName'].should.equal('my_subnet_group')
 
 
+@mock_redshift
+@mock_ec2
+def test_create_cluster_in_subnet_group_boto3():
+    ec2 = boto3.resource('ec2', region_name='us-east-1')
+    vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
+    subnet = ec2.create_subnet(VpcId=vpc.id, CidrBlock='10.0.0.0/24')
+    client = boto3.client('redshift', region_name='us-east-1')
+    client.create_cluster_subnet_group(
+        ClusterSubnetGroupName='my_subnet_group',
+        Description='This is my subnet group',
+        SubnetIds=[subnet.id]
+    )
+
+    client.create_cluster(
+        ClusterIdentifier="my_cluster",
+        NodeType="dw.hs1.xlarge",
+        MasterUsername="username",
+        MasterUserPassword="password",
+        ClusterSubnetGroupName='my_subnet_group',
+    )
+
+    cluster_response = client.describe_clusters(ClusterIdentifier="my_cluster")
+    cluster = cluster_response['Clusters'][0]
+    cluster['ClusterSubnetGroupName'].should.equal('my_subnet_group')
+
+
 @mock_redshift_deprecated
 def test_create_cluster_with_security_group():
     conn = boto.redshift.connect_to_region("us-east-1")