From b9b93095a9c5f20d27b46d564f1f464e19dc8f25 Mon Sep 17 00:00:00 2001 From: JSpon <115185500+JSpon@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:58:48 -0500 Subject: [PATCH] Allow multiple nics --- cloudstack/resource_cloudstack_instance.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cloudstack/resource_cloudstack_instance.go b/cloudstack/resource_cloudstack_instance.go index fdf77ee9..8b188eb7 100644 --- a/cloudstack/resource_cloudstack_instance.go +++ b/cloudstack/resource_cloudstack_instance.go @@ -64,6 +64,14 @@ func resourceCloudStackInstance() *schema.Resource { Optional: true, Computed: true, ForceNew: true, + ConflictsWith: []string{"network_ids"}, + }, + + "network_ids": { + Type: schema.TypeList, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + ConflictsWith: []string{"network_id"}, }, "ip_address": { @@ -307,6 +315,14 @@ func resourceCloudStackInstanceCreate(d *schema.ResourceData, meta interface{}) p.SetNetworkids([]string{d.Get("network_id").(string)}) } + if networks, ok := d.GetOk("network_ids"); ok { + var networkIds []string + for _, nw := range networks.([]interface{}) { + networkIds = append(networkIds, fmt.Sprintf("%v", nw)) + } + p.SetNetworkids(networkIds); + } + // If there is a ipaddres supplied, add it to the parameter struct if ipaddress, ok := d.GetOk("ip_address"); ok { p.SetIpaddress(ipaddress.(string))