diff --git a/docs/source/cloud-setup/cloud-permissions/aws.rst b/docs/source/cloud-setup/cloud-permissions/aws.rst index 89510331988..57fc7ac9732 100644 --- a/docs/source/cloud-setup/cloud-permissions/aws.rst +++ b/docs/source/cloud-setup/cloud-permissions/aws.rst @@ -223,7 +223,7 @@ IAM Role Creation Using a specific VPC ----------------------- -By default, SkyPilot uses the "default" VPC in each region. +By default, SkyPilot uses the "default" VPC in each region. If a region does not have a `default VPC `_, SkyPilot will not be able to use the region. To instruct SkyPilot to use a specific VPC, you can use SkyPilot's global config file ``~/.sky/config.yaml`` to specify the VPC name in the ``aws.vpc_name`` diff --git a/sky/provision/aws/config.py b/sky/provision/aws/config.py index ffa87c3a011..acc6fcb0e56 100644 --- a/sky/provision/aws/config.py +++ b/sky/provision/aws/config.py @@ -383,10 +383,13 @@ def _get_pruned_subnets(current_subnets: List[Any]) -> Set[str]: raise exc if not subnets: + vpc_msg = (f'Does a default VPC exist in region ' + f'{ec2.meta.client.meta.region_name}? ') if ( + vpc_id_of_sg is None) else '' _skypilot_log_error_and_exit_for_failover( - 'No usable subnets found, try ' - 'manually creating an instance in your specified region to ' - 'populate the list of subnets and trying this again. ' + f'No usable subnets found. {vpc_msg}' + 'Try manually creating an instance in your specified region to ' + 'populate the list of subnets and try again. ' 'Note that the subnet must map public IPs ' 'on instance launch unless you set `use_internal_ips: true` in ' 'the `provider` config.') @@ -495,6 +498,11 @@ def _get_subnet_and_vpc_id(ec2, security_group_ids: Optional[List[str]], vpc_id_of_sg = None all_subnets = list(ec2.subnets.all()) + # If no VPC is specified, use the default VPC. + # We filter only for default VPCs to avoid using subnets that users may + # not want SkyPilot to use. + if vpc_id_of_sg is None: + all_subnets = [s for s in all_subnets if s.vpc.is_default] subnets, vpc_id = _usable_subnets( ec2, user_specified_subnets=None,