Skip to content

Commit

Permalink
Rename vpc to vpc_name in aws config
Browse files Browse the repository at this point in the history
(cherry picked from commit 2e17664)
  • Loading branch information
r4victor authored and peterschmidt85 committed Feb 13, 2024
1 parent a921c1e commit 73c2d62
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/dstack/_internal/core/backends/aws/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ def run_job(
try:
subnet_id = None
vpc_id = None
if self.config.vpc is not None:
if self.config.vpc_name is not None:
vpc_id = aws_resources.get_vpc_id_by_name(
ec2_client=ec2_client,
vpc_name=self.config.vpc,
vpc_name=self.config.vpc_name,
)
if vpc_id is None:
raise ComputeError(
f"No VPC named {self.config.vpc} in region {instance_offer.region}"
f"No VPC named {self.config.vpc_name} in region {instance_offer.region}"
)
subnet_id = aws_resources.get_subnet_id_for_vpc(
ec2_client=ec2_client,
vpc_id=vpc_id,
)
if subnet_id is None:
raise ComputeError(
f"Failed to get subnet for VPC {self.config.vpc} in region {instance_offer.region}"
f"Failed to get subnet for VPC {self.config.vpc_name} in region {instance_offer.region}"
)
disk_size = round(instance_offer.instance.resources.disk.size_mib / 1024)
response = ec2.create_instances(
Expand Down
2 changes: 1 addition & 1 deletion src/dstack/_internal/core/models/backends/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class AWSConfigInfo(BaseModel):
type: Literal["aws"] = "aws"
regions: Optional[List[str]] = None
vpc: Optional[str] = None
vpc_name: Optional[str] = None


class AWSAccessKeyCreds(ForbidExtra):
Expand Down
2 changes: 1 addition & 1 deletion src/dstack/_internal/server/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
class AWSConfig(ForbidExtra):
type: Literal["aws"] = "aws"
regions: Optional[List[str]] = None
vpc: Optional[str] = None
vpc_name: Optional[str] = None
creds: AnyAWSCreds = Field(..., discriminator="type")


Expand Down
2 changes: 1 addition & 1 deletion src/tests/_internal/server/routers/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,6 @@ async def test_returns_config_info(self, test_db, session: AsyncSession):
assert response.json() == {
"type": "aws",
"regions": json.loads(backend.config)["regions"],
"vpc": None,
"vpc_name": None,
"creds": json.loads(backend.auth),
}
2 changes: 1 addition & 1 deletion src/tests/_internal/server/routers/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def test_returns_projects(self, test_db, session: AsyncSession):
"config": {
"type": backend.type,
"regions": json.loads(backend.config)["regions"],
"vpc": None,
"vpc_name": None,
},
}
],
Expand Down

0 comments on commit 73c2d62

Please sign in to comment.