selectSubnet throws when trying to select a type that wasn't created [aws-ec2] #11205
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
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
What did you expect to happen?
I expected an empty set or
undefined
returnedWhat actually happened?
Error
There are no 'Private' subnet groups in this VPC. Available types: Isolated,Public
was thrownEnvironment
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
The text was updated successfully, but these errors were encountered: