Skip to content

Commit

Permalink
Merge pull request #528 from MusicDin/docs/attach-example
Browse files Browse the repository at this point in the history
docs: Move attach custom volume example to lxd_volume
  • Loading branch information
simondeziel authored Sep 20, 2024
2 parents e14c31b + 242f256 commit b409862
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 32 deletions.
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

0 comments on commit b409862

Please sign in to comment.