Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Move attach custom volume example to lxd_volume #528

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
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
29 changes: 0 additions & 29 deletions docs/resources/instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,6 @@ resource "lxd_instance" "instance1" {
}
```

## Example to Attach a Volume

```hcl
resource "lxd_storage_pool" "pool1" {
name = "mypool"
driver = "zfs"
}

resource "lxd_volume" "volume1" {
name = "myvolume"
pool = lxd_storage_pool.pool1.name
}

resource "lxd_instance" "instance1" {
name = "%s"
image = "ubuntu"

device {
name = "volume1"
type = "disk"
properties = {
path = "/mount/point/in/instance"
source = lxd_volume.volume1.name
pool = lxd_storage_pool.pool1.name
}
}
}
```

## Example to proxy/forward ports

```hcl
Expand Down
43 changes: 40 additions & 3 deletions docs/resources/volume.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,52 @@ Manages an LXD volume.

## Example Usage

Example of how to create a custom storage pool volume:
```hcl
resource "lxd_storage_pool" "pool1" {
resource "lxd_storage_pool" "pool" {
name = "mypool"
driver = "zfs"
}

resource "lxd_volume" "volume1" {
resource "lxd_volume" "volume" {
name = "myvolume"
pool = lxd_storage_pool.pool1.name
pool = lxd_storage_pool.pool.name
}
```

Example of how to create and attach a custom storage pool volume to an instance:
```hcl
# Create storage pool.
resource "lxd_storage_pool" "pool" {
name = "mypool"
driver = "zfs"
}

# Create custom volume.
resource "lxd_volume" "volume" {
name = "myvol"
pool = lxd_storage_pool.pool.name

config = {
size = "5GiB"
}
}

# Create an instance with attached custom volume.
resource "lxd_instance" "instance" {
name = "myinstance"
image = "ubuntu:22.04"

# Attach additional volume.
device {
name = "vol-01"
type = "disk"
properties = {
path = "/var/lib/docker" # Path where volume is mounted within an instance.
pool = lxd_storage_pool.pool.name # Storage pool name where volume is created.
source = lxd_volume.volume.name # Volume name.
}
}
}
```

Expand Down