aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.68k stars 3.93k forks source link

[aws-rds] Cannot create an Aurora Serverless CfnDbCluster in non-default VPC #10139

Closed slushysnowman closed 4 years ago

slushysnowman commented 4 years ago

When trying to create an Aurora Serverless Cluster using CfnDbCluster in a non-default VPC, I get an error:

8:50:51 PM | CREATE_FAILED        | AWS::RDS::DBCluster                       | ClusterResourceName
No default subnet detected in VPC. Please contact AWS Support to recreate default Subnets. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidSubnet; Request ID: <REQUESTID>; Pro
xy: null)

The subnets I am trying to use are in a non-default VPC.

Reproduction Steps

        vpc = ec2.Vpc.from_lookup(
            self, 'ExistingVpc',
            vpc_id=vpc_id
        )

        db_subnet_group = rds.CfnDBSubnetGroup(
            self, 'DbSubnetGroup',
            db_subnet_group_description='Subnet Group',
            subnet_ids=vpc.select_subnets(subnet_type=ec2.SubnetType.PRIVATE).subnet_ids
        )

        db_cluster = rds.CfnDBCluster(
            self, 'AuroraServerlessCluster',
            database_name='dbname',
            db_cluster_identifier='DbCluster',
            engine='aurora-postgresql',
            engine_mode='serverless',
            master_username=db_secret.secret_value_from_json('username').to_string(),
            master_user_password=db_secret.secret_value_from_json('password').to_string(),
            port=5432,
            db_subnet_group_name=db_subnet_group.db_subnet_group_name,
            scaling_configuration={},
            vpc_security_group_ids=[
                sec_group_asg.security_group_id
            ]
        )

        db_cluster.add_override("Properties.ScalingConfiguration", { 
            'AutoPause': True, 
            'MaxCapacity': 2, 
            'MinCapacity': 1, 
            'SecondsUntilAutoPause': 300
        })

What did you expect to happen?

Cluster should have been created in non-default VPC

What actually happened?

8:50:51 PM | CREATE_FAILED | AWS::RDS::DBCluster | ClusterResourceName No default subnet detected in VPC. Please contact AWS Support to recreate default Subnets. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidSubnet; Request ID: ; Pro xy: null)

Environment

Other


This is :bug: Bug Report

slushysnowman commented 4 years ago

Nevermind, closing this - turns out the issue was with how I was referencing the DB subnet group.

I was doing: db_subnet_group_name=db_subnet_group.db_subnet_group_name but should have been doing: db_subnet_group_name=db_subnet_group.ref