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

selectSubnet throws when trying to select a type that wasn't created [aws-ec2] #11205

Closed
pszabop opened this issue Oct 29, 2020 · 3 comments
Closed
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@pszabop
Copy link

pszabop commented Oct 29, 2020

When attempting to call ec2.vpc.selectSubnet(), which from the name sounds like a query, if no subnets exist given the criteria an error is thrown instead of an empty set returned.

Reproduction Steps

const fileSystemVpc = new ec2.Vpc(this, 'vpcForEfs', {
  natGateways: 0,
  maxAzs: 2,
});

// THIS ASSERTS and is a bug in ec2.vpc
// it should just return an empty set or undefined
const privateSubnets = fileSystemVpc.selectSubnets({
  subnetType: ec2.SubnetType.PRIVATE,
});

What did you expect to happen?

I expected an empty set or undefined returned

What actually happened?

Error There are no 'Private' subnet groups in this VPC. Available types: Isolated,Public was thrown

Environment

  • **CLI Version :1.63
  • **Framework Version:1.63
  • **Node.js Version:12.16.1
  • **OS :Linux
  • **Language (Version):Typescript 3.7.5

Other

I have branches in my code that would like to know whether certain subnets exist or not, and right now I have to catch/throw for this exception as a work around. The exception is hard-coded in the aws-ec2 module and doesn't follow exception
best practices so I have to use a regular expression to look for it rather than looking up an exception type in a map or object. This makes the code fragile since you could change the text at any time.


This is 🐛 Bug Report

@pszabop pszabop added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 29, 2020
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Oct 29, 2020
@rix0rrr rix0rrr added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 and removed bug This issue is a bug. labels Nov 2, 2020
@rix0rrr
Copy link
Contributor

rix0rrr commented Nov 2, 2020

Take into account for #5927

@SomayaB SomayaB removed the needs-triage This issue or PR still needs to be triaged. label Nov 2, 2020
@rix0rrr rix0rrr removed their assignment Jun 3, 2021
@github-actions
Copy link

github-actions bot commented Jun 3, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Jun 3, 2022
@github-actions github-actions bot closed this as completed Jun 8, 2022
@ramesh82
Copy link

I am currently using try catch to handle the exception but it would be good to return empty or null if the subnet types/groups doesn't exist.

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 closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

4 participants