[Bug]: If one region/vpc_id is specified, they *all* need to be specified
Steps to reproduce
use the AWS backend and set 1 region/vpc_id pair under vpc_ids in ~/.dstack/server/config.yml.
Actual behaviour
The backend complains about not having a VPC for a region you didn't specify, rather than using the default vpc for that region.
Expected behaviour
If you specify a VPC for only 1 region, I would expect all other regions to default to the default VPC.
dstack version
0.18.1
Server logs
No response
Additional information
No response
@spott, this is actually intended. The idea being is that you may want to use non-default VPCs for security reasons, in which case you don't want to accidentally use default VPCs. You can always specify default VPCs explicitly if they work for you.
Could you please provide a use case when you may want to use a specific non-default VPCs in some regions and default VPCs in other regions?
Cross-region vpcs (that are actually connected), are expensive. So we have some code that requires being in a VPC (and we run that code in that region) and other code that doesn't require being in a VPC, which we run in any region (so that we can get the best prices/availability).
I can see the security concern... in that case, I think being able to define fallback rules might be valuable. For example:
vpc_ids:
- all-regions: default
- us-east-1: <my special vpc id>
This allows a user to define a special VPC without finding the default VPC id for every other region (not hard, but not fantastic UX), and without writing out every region name if you want to change one of them.
@spott, Thanks for the clarification! So I think we need to support both cases:
- Users want to use default VPCs if vpc_ids are not specified in some regions.
- Users want to see an error if vpc_ids are not specified in some regions so that default VPCs are never used.
You approach should work, but I would suggest a different syntax. We may use default VPCs for non-specified regions by default (as you expect), and introduce a default_vpcs: true/false configuration parameter for those who want to force strict vpc_ids validation. This parameter would also play nicely with vpc_name – dstack will use / not use default VPCs if VPCs are not found by name in some regions.
I'm sorry for the late reply...
I like your syntax, though I thought I would throw out an edge case in to think about:
If I want to use vpc_a (which is not the default vpc) for all regions except for a special region, then I'm back to writing out that vpc for every region.
This is enough of an edge case that I wouldn't design around it for now, but I thought of it and I thought I would share.
Honestly, I don't see a succinct syntax that would cover all edge cases without it being too clever. After all, enumerating all vpc ids is always an option and it doesn't seem to be that hard to do.
As for the initial case, I'm inclined to proceed with adding default_vpcs and also improving error messages, warnings, docs.