> For the complete documentation index, see [llms.txt](https://docs.acecloud.ai/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.acecloud.ai/knowledge-base/cli/networking/vpcs.md).

# VPCs

VPCs (Virtual Private Clouds) are isolated network environments for your cloud resources. Each VPC contains one or more subnets that define IP address ranges for instances.

**Command:** `ace vpc` **Alias:** `ace network`

## Create a VPC

Create a new VPC, optionally with a subnet in the same call.

```bash
ace vpc create --name <name> [flags]
```

### Flags

| Flag            | Required | Description                               |
| --------------- | -------- | ----------------------------------------- |
| `--name`        | Yes      | VPC name                                  |
| `--description` | No       | VPC description                           |
| `--subnet-name` | No       | Subnet name (creates subnet with the VPC) |
| `--subnet-cidr` | No       | Subnet CIDR block (e.g. `10.0.0.0/24`)    |
| `--gateway-ip`  | No       | Subnet gateway IP address                 |
| `--dns`         | No       | DNS nameservers (repeatable)              |

If you provide `--subnet-name`, you must also provide `--subnet-cidr`, and vice versa.

> **Note** — `ace vpc create` requires at least one subnet definition (the backend rejects a VPC-only create). Pass `--subnet-name` + `--subnet-cidr`, or create the subnet separately afterwards with `ace vpc subnet-create`.

### Examples

Create a VPC with a subnet:

```bash
ace vpc create --name my-vpc \
  --subnet-name my-subnet \
  --subnet-cidr 10.0.0.0/24
```

Create a VPC with custom gateway and DNS:

```bash
ace vpc create --name my-vpc \
  --subnet-name my-subnet \
  --subnet-cidr 10.0.0.0/24 \
  --gateway-ip 10.0.0.1 \
  --dns 8.8.8.8 \
  --dns 8.8.4.4
```

Create a VPC without a subnet (add subnets later):

```bash
ace vpc create --name my-vpc
```

### Sample Output

```
VPC created.
  VPC ID:          a1b2c3d4-e5f6-7890-abcd-ef1234567890
  Name:            my-vpc
  Status:          ACTIVE
  Subnet ID:       f6e5d4c3-b2a1-0987-fedc-ba0987654321
  Subnet Name:     my-subnet
  Subnet CIDR:     10.0.0.0/24
  Gateway IP:      10.0.0.1
```

***

## List VPCs

```bash
ace vpc list
```

**Alias:** `ace vpc ls`

### Sample Output

```
ID                                     NAME                      STATUS     SHARED   SUBNETS  DESCRIPTION
a1b2c3d4-e5f6-7890-abcd-ef1234567890  my-vpc                    ACTIVE     false    1
d4c3b2a1-f6e5-0987-dcba-123456789abc  default                   ACTIVE     true     2        Default network
```

### JSON Output

```bash
ace vpc list -o json
```

***

## Get VPC Details

```bash
ace vpc get <vpc-id>
```

### Sample Output

```
  ID:                       a1b2c3d4-e5f6-7890-abcd-ef1234567890
  Name:                     my-vpc
  Status:                   ACTIVE
  Shared:                   false
  Port Security:            true
  Admin State Up:           true
  Subnets:                  1
    my-subnet               10.0.0.0/24          10.0.0.1
  Created:                  2025-01-15T10:30:00Z
  Updated:                  2025-01-15T10:30:00Z
```

***

## Update a VPC

Rename a VPC or change its description.

```bash
ace vpc update <vpc-id> [flags]
```

### Flags

| Flag            | Description     |
| --------------- | --------------- |
| `--name`        | New VPC name    |
| `--description` | New description |

At least one of `--name` or `--description` must be provided.

### Example

```bash
ace vpc update a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
  --name my-vpc-renamed \
  --description "production VPC"
```

### Sample Output

```
VPC updated.
  VPC ID:          a1b2c3d4-e5f6-7890-abcd-ef1234567890
  Name:            my-vpc-renamed
  Description:     production VPC
```

***

## Delete VPCs

Delete one or more VPCs by ID.

```bash
ace vpc delete <vpc-id> [vpc-id...]
```

**Alias:** `ace vpc rm`

A VPC cannot be deleted while it has active subnets, ports, or attached resources. Delete all resources in the VPC first.

### Example

```bash
# Delete a single VPC
ace vpc delete a1b2c3d4-e5f6-7890-abcd-ef1234567890

# Delete multiple VPCs
ace vpc delete <vpc-id-1> <vpc-id-2>
```

***

## Subnet Management

### Create a Subnet

Add a subnet to an existing VPC.

```bash
ace vpc subnet-create --vpc <vpc-id> --name <name> --cidr <cidr> [flags]
```

#### Flags

| Flag           | Required | Description                     |
| -------------- | -------- | ------------------------------- |
| `--vpc`        | Yes      | VPC ID to add the subnet to     |
| `--name`       | Yes      | Subnet name                     |
| `--cidr`       | Yes      | CIDR block (e.g. `10.0.1.0/24`) |
| `--gateway-ip` | No       | Gateway IP address              |
| `--dns`        | No       | DNS nameservers (repeatable)    |

#### Examples

```bash
# Basic subnet
ace vpc subnet-create --vpc <vpc-id> --name backend-subnet --cidr 10.0.1.0/24

# With custom gateway
ace vpc subnet-create --vpc <vpc-id> --name backend-subnet \
  --cidr 10.0.1.0/24 \
  --gateway-ip 10.0.1.1
```

#### Sample Output

```
Subnet created.
  Subnet ID:       f6e5d4c3-b2a1-0987-fedc-ba0987654321
  Name:            backend-subnet
  CIDR:            10.0.1.0/24
  Gateway IP:      10.0.1.1
```

### Delete Subnets

Delete one or more subnets by ID.

```bash
ace vpc subnet-delete <subnet-id> [subnet-id...]
```

#### Example

```bash
ace vpc subnet-delete f6e5d4c3-b2a1-0987-fedc-ba0987654321
```

```
Deleted 1 subnet(s).
```

***

## Command Summary

| Command                      | Description                        |
| ---------------------------- | ---------------------------------- |
| `ace vpc create`             | Create a VPC (with subnet)         |
| `ace vpc list`               | List all VPCs                      |
| `ace vpc get <id>`           | Get VPC details                    |
| `ace vpc update <id>`        | Rename / re-describe a VPC         |
| `ace vpc delete <id>`        | Delete VPC(s)                      |
| `ace vpc subnet-create`      | Create a subnet in an existing VPC |
| `ace vpc subnet-delete <id>` | Delete subnet(s)                   |
