Skip to content

Feature Request: Add boot_mode support to cloudstack_instance #250

@HeinzM

Description

@HeinzM

Feature Request

Summary

Add support for specifying the VM boot mode (Secure or Legacy) in the cloudstack_instance resource, alongside the existing uefi option.


Current Behavior

At the moment, Terraform users can enable UEFI booting with:

uefi = true

However, there is no way to control the boot mode, although the CloudStack API supports this via the bootmode parameter in deployVirtualMachine.

Proposed Enhancement

Introduce a new optional argument boot_mode to the cloudstack_instance resource.

resource "cloudstack_instance" "example" {
  name              = "vm-secureboot"
  service_offering  = "Small Instance"
  template          = "ubuntu-uefi"
  zone              = "zone1"
  network_id        = "net-123"

  uefi       = true
  boot_mode  = "Secure"   # or "Legacy"
}

Behavior

  • If uefi = false, boot_mode should be ignored or validated as unsupported.
  • If uefi = true and boot_mode is not provided, default to "Legacy".
  • Accepted values: "Secure", "Legacy" (case-insensitive).
  • The value should map directly to the CloudStack API field bootmode.

Relationale

UEFI + Secure Boot are increasingly required in enterprise and compliance environments.
CloudStack supports these features natively since v4.14+( according to Cloudstack API Documentation), but Terraform users cannot currently configure Secure Boot declaratively.
Adding boot_mode makes the Terraform provider feature-complete for UEFI-capable VMs.

References

Implementation Hints

func resourceCloudStackInstance() *schema.Resource :

"boot_mode": {
  Type:         schema.TypeString,
  Optional:     true,
  ValidateFunc: validation.StringInSlice([]string{"Secure", "Legacy"}, true),
},

Map this field to the CloudStack API parameter bootmode.

There is already a conditional for the uefi value in func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) error.

if d.Get("uefi").(bool) {
  p.SetBoottype("UEFI")
  p.SetBootmode("Legacy")
}

But bootmode is statically set to "Legacy"

Acceptance Criteria

  • boot_mode can be set on cloudstack_instance.
  • The parameter is passed correctly to deployVirtualMachine.
  • The VM’s actual boot mode is reflected in Terraform state.
  • Documentation and examples are updated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions