Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions apps/Cloud-Computer-Control-Panel/lib/aws-ec2-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,18 @@ export async function createOrGetDokploySecurityGroup(
return { groupId: existingGroups[0].groupId }
}

// Get default VPC
// Get VPC - prefer default VPC, but fall back to first available VPC
const vpcs = await describeVpcs(accessKeyId, secretAccessKey, region)
const defaultVpc = vpcs.find((v) => v.isDefault)
const targetVpc = defaultVpc || vpcs[0]

if (!targetVpc) {
throw new Error("No VPC available in this region. Please create a VPC first.")
}

console.log(
`[EC2] Using VPC ${targetVpc.vpcId} (${defaultVpc ? "default" : "first available"}) for security group`,
)

// Create security group
const { groupId } = await createSecurityGroup(
Expand All @@ -451,7 +460,7 @@ export async function createOrGetDokploySecurityGroup(
region,
"dokploy-sg",
"Dokploy security group - SSH, HTTP, HTTPS, and port 3000",
defaultVpc?.vpcId,
targetVpc.vpcId,
)

if (!groupId) {
Expand Down