Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPC shouldn't select 0 subnets in "dummy" mode #6115

Closed
davidh83110 opened this issue Feb 5, 2020 · 0 comments · Fixed by #7666
Closed

VPC shouldn't select 0 subnets in "dummy" mode #6115

davidh83110 opened this issue Feb 5, 2020 · 0 comments · Fixed by #7666
Assignees
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. p1

Comments

@davidh83110
Copy link

davidh83110 commented Feb 5, 2020

When I was using ec2.Vpc.fromLookup with my RDS, it couldn't fetch the correct VPC and keep showing me vpc-12345 which is obviously not my VPC ID. However, after I removed the new rds.DatabaseCluster() creation code which only left Vpc.fromLookup, it backed to normal.

Reproduction Steps

My code:

   // VPC
    const vpc = ec2.Vpc.fromLookup(this, 'vpc', {
      vpcName: vpcName
    })

    console.log(vpc.vpcId)

    // RDS - Aurora MySQL
    new rds.DatabaseCluster(this, 'rds', {
      clusterIdentifier: dbName,
      engine: rds.DatabaseClusterEngine.AURORA_MYSQL,
      engineVersion: dbEngineVersion,
      storageEncrypted: true,
      parameterGroup: rdsParameterGroup,
      masterUser: {
          username: 'root',
          password: cdk.SecretValue.ssmSecure('Password', '1')
      },
      instanceProps: {
        instanceType: ec2.InstanceType.of(ec2.InstanceClass.T3, ec2.InstanceSize.MEDIUM),
        vpc: vpcXrex,
        vpcSubnets: {
          subnetGroupName: 'db'
        },
        securityGroup: rdsSG
      }
    })

And I ran cdk diff, I got this.

➜  rds-aurora git:(develop) ✗ aws-vault exec staging -- cdk diff
vpc-12345
Cluster requires at least 2 subnets, got 0
Subprocess exited with error 1

After I removed new rds.DatabaseCluster, it backed to normal.

➜  rds-aurora git:(develop) ✗ aws-vault exec staging -- cdk diff
vpc-12345
vpc-03eaf74111
Stack RdsAuroraStack
There were no differences

Then I was trying to run again

➜  rds-aurora git:(develop) ✗ aws-vault exec staging -- cdk diff
vpc-03eaf74111
Stack RdsAuroraStack
There were no differences

At lastly, I added the rds backed. It becomes normal.

➜  rds-aurora git:(develop) ✗ aws-vault exec staging -- cdk diff
vpc-03eaf74111
Stack RdsAuroraStack

Resources
[+] AWS::RDS::DBSubnetGroup rds/Subnets rdsSubnet111
[+] AWS::RDS::DBCluster rds rds111
[+] AWS::RDS::DBInstance rds/Instance1 rdsInstance111
[+] AWS::RDS::DBInstance rds/Instance2 rdsInstance111

Environment

  • CLI Version : 1.22.0
  • Framework Version: typescript 3.7.5
  • OS : macOS-Catalina 10.15.2
  • Language : typescript

Other

Is there anyone who also encountered the same issue on ec2.Vpc.fromLookup?
The workaround to me is to remove rds.DatabaseCluster first, then run cdk diff and add it back and run again.


This is 🐛 Bug Report

@davidh83110 davidh83110 added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2020
@SomayaB SomayaB added @aws-cdk/aws-rds Related to Amazon Relational Database package/vpc labels Feb 5, 2020
@rix0rrr rix0rrr changed the title Can't import correct VPC on Vpc.fromLookup Vpc.fromLookup dummy VPC fails RDS subnet check Feb 6, 2020
@rix0rrr rix0rrr added the p1 label Feb 6, 2020
@rix0rrr rix0rrr removed the @aws-cdk/aws-rds Related to Amazon Relational Database label Feb 6, 2020
@rix0rrr rix0rrr changed the title Vpc.fromLookup dummy VPC fails RDS subnet check VPC shouldn't select 0 subnets in "dummy" mode Feb 6, 2020
@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Mar 5, 2020
rix0rrr added a commit that referenced this issue Apr 29, 2020
Specific subnet group names in an imported VPC may be missing
from the Dummy version of the imported VPC, leading to an exception
which aborts.

Turn the exception into a Construct error, which simply prevents deployment
of an incomplete construct instead of a complete abort.

Fixes #6115.
@mergify mergify bot closed this as completed in #7666 Apr 30, 2020
mergify bot pushed a commit that referenced this issue Apr 30, 2020
Specific subnet group names in an imported VPC may be missing
from the Dummy version of the imported VPC, leading to an exception
which aborts.

Turn the exception into a Construct error, which simply prevents deployment
of an incomplete construct instead of a complete abort.

Fixes #6115.
@SomayaB SomayaB added @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud and removed package/vpc labels May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud bug This issue is a bug. p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants