This is an automated email from the ASF dual-hosted git repository. pearl11594 pushed a commit to branch add-boot-mode-for-instance in repository https://gitbox.apache.org/repos/asf/cloudstack-terraform-provider.git
commit 5ef51183a10ec17be11f308fa229c84c7968969b Author: Pearl Dsilva <[email protected]> AuthorDate: Fri Oct 17 11:29:57 2025 -0400 Add support boot mode when UEFI true --- cloudstack/resource_cloudstack_instance.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go index 06c84f4..cfcf8d4 100644 --- a/cloudstack/resource_cloudstack_instance.go +++ b/cloudstack/resource_cloudstack_instance.go @@ -29,6 +29,7 @@ import ( "github.com/apache/cloudstack-go/v2/cloudstack" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" ) func resourceCloudStackInstance() *schema.Resource { @@ -182,6 +183,13 @@ func resourceCloudStackInstance() *schema.Resource { Default: false, }, + "boot_mode": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{"Secure", "Legacy"}, true), + ForceNew: true, + }, + "start_vm": { Type: schema.TypeBool, Optional: true, @@ -262,6 +270,10 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) return e.Error() } + if bootMode, hasBoot := d.GetOk("boot_mode"); hasBoot && !d.Get("uefi").(bool) { + return fmt.Errorf("boot_mode can only be specified when uefi is true, got boot_mode=%s with uefi=false", bootMode.(string)) + } + // Create a new parameter struct p := cs.VirtualMachine.NewDeployVirtualMachineParams(serviceofferingid, templateid, zone.Id) p.SetStartvm(d.Get("start_vm").(bool)) @@ -331,7 +343,11 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) if d.Get("uefi").(bool) { p.SetBoottype("UEFI") - p.SetBootmode("Legacy") + if bootmode, ok := d.GetOk("boot_mode"); ok { + p.SetBootmode(bootmode.(string)) + } else { + p.SetBootmode("Legacy") + } } if zone.Networktype == "Advanced" { @@ -538,6 +554,10 @@ func resourceCloudStackInstanceRead(d *schema.ResourceData, meta interface{}) er setValueOrID(d, "template", vm.Templatename, vm.Templateid) setValueOrID(d, "project", vm.Project, vm.Projectid) setValueOrID(d, "zone", vm.Zonename, vm.Zoneid) + d.Set("uefi", vm.Boottype == "UEFI") + if vm.Boottype == "UEFI" && vm.Bootmode != "" { + d.Set("boot_mode", vm.Bootmode) + } return nil }
