diff --git a/docs/resources/instance.md b/docs/resources/instance.md index 0aa73e5..7814b39 100644 --- a/docs/resources/instance.md +++ b/docs/resources/instance.md @@ -17,12 +17,15 @@ Multipass instance resource. ### Required -- `name` (String) +- `name` (String) Name for the instance. If it is 'primary' (the configured primary instance name), the user's home directory is mounted inside the newly launched instance, in 'Home'. ### Optional -- `cpus` (Number) -- `image` (String) +- `cloudinit_file` (String) Path to a user-data cloud-init configuration. +- `cpus` (Number) Number of CPUs to allocate. Minimum: 1, default: 1. +- `disk` (String) Disk space to allocate. Positive integers, in bytes, or with K, M, G suffix. Minimum: 512M, default: 5G. +- `image` (String) Optional image to launch. If omitted, then the default Ubuntu LTS will be used. can be either ‘release’ or ‘daily‘. If is omitted, ‘release’ will be used. can be a partial image hash or an Ubuntu release version, codename or alias. is a custom image URL that is in http://, https://, or file:// format. +- `memory` (String) Amount of memory to allocate. Positive integers, in bytes, or with K, M, G suffix. Minimum: 128M, default: 1G. ### Read-Only diff --git a/multipass/resource_instance.go b/multipass/resource_instance.go index be143b3..5ac96db 100644 --- a/multipass/resource_instance.go +++ b/multipass/resource_instance.go @@ -19,20 +19,52 @@ func resourceInstance() *schema.Resource { Schema: map[string]*schema.Schema{ "name": { + Description: "Name for the instance. If it is 'primary' " + + "(the configured primary instance name), the user's " + + "home directory is mounted inside the newly launched " + + "instance, in 'Home'.", Type: schema.TypeString, Required: true, ForceNew: true, }, "image": { + Description: "Optional image to launch. If omitted, then " + + "the default Ubuntu LTS will be used. can be " + + "either ‘release’ or ‘daily‘. If is " + + "omitted, ‘release’ will be used. can be a " + + "partial image hash or an Ubuntu release version, " + + "codename or alias. is a custom image URL " + + "that is in http://, https://, or file:// format.", Type: schema.TypeString, Optional: true, ForceNew: true, }, "cpus": { - Type: schema.TypeInt, + Description: "Number of CPUs to allocate. Minimum: 1, default: 1.", + Type: schema.TypeInt, + Optional: true, + ForceNew: true, + }, + "memory": { + Description: "Amount of memory to allocate. Positive integers, " + + "in bytes, or with K, M, G suffix. Minimum: 128M, default: 1G.", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, + "disk": { + Description: "Disk space to allocate. Positive integers, in bytes, " + + "or with K, M, G suffix. Minimum: 512M, default: 5G.", + Type: schema.TypeString, Optional: true, ForceNew: true, }, + "cloudinit_file": { + Description: "Path to a user-data cloud-init configuration.", + Type: schema.TypeString, + Optional: true, + ForceNew: true, + }, }, } } @@ -55,15 +87,15 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interfa func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { name := d.Get("name").(string) - image := d.Get("image").(string) - cpus := d.Get("cpus").(int) - d.SetId(name) _, err := multipass.Launch(&multipass.LaunchReq{ - Image: image, - Name: name, - CPU: cpus, + Name: name, + Image: d.Get("image").(string), + CPU: d.Get("cpus").(int), + Memory: d.Get("memory").(string), + Disk: d.Get("disk").(string), + CloudInitFile: d.Get("cloudinit_file").(string), }) if err != nil {