Merge pull request #1030 from JackDanger/boto3-redshift
Allow boto3 redshift cluster subnet group creation
This commit is contained in:
commit
1dcddf3a7e
@ -122,6 +122,10 @@ class RedshiftResponse(BaseResponse):
|
|||||||
cluster_subnet_group_name = self._get_param('ClusterSubnetGroupName')
|
cluster_subnet_group_name = self._get_param('ClusterSubnetGroupName')
|
||||||
description = self._get_param('Description')
|
description = self._get_param('Description')
|
||||||
subnet_ids = self._get_multi_param('SubnetIds.member')
|
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(
|
subnet_group = self.redshift_backend.create_cluster_subnet_group(
|
||||||
cluster_subnet_group_name=cluster_subnet_group_name,
|
cluster_subnet_group_name=cluster_subnet_group_name,
|
||||||
|
@ -11,7 +11,10 @@ from boto.redshift.exceptions import (
|
|||||||
)
|
)
|
||||||
import sure # noqa
|
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
|
@mock_redshift
|
||||||
@ -153,6 +156,32 @@ def test_create_cluster_in_subnet_group():
|
|||||||
cluster['ClusterSubnetGroupName'].should.equal('my_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
|
@mock_redshift_deprecated
|
||||||
def test_create_cluster_with_security_group():
|
def test_create_cluster_with_security_group():
|
||||||
conn = boto.redshift.connect_to_region("us-east-1")
|
conn = boto.redshift.connect_to_region("us-east-1")
|
||||||
|
Loading…
Reference in New Issue
Block a user