Skip to content

Commit a3c6fec

Browse files
author
Sander van Harmelen
authored
Properly support secundary IP addresses (hashicorp#10420)
And remove the deprecated `network_id` field.
1 parent facce68 commit a3c6fec

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

builtin/providers/cloudstack/resource_cloudstack_static_nat.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,6 @@ func resourceCloudStackStaticNAT() *schema.Resource {
2323
ForceNew: true,
2424
},
2525

26-
"network_id": &schema.Schema{
27-
Type: schema.TypeString,
28-
Optional: true,
29-
ForceNew: true,
30-
Deprecated: "network_id is deprecated and can be safely omitted",
31-
},
32-
3326
"virtual_machine_id": &schema.Schema{
3427
Type: schema.TypeString,
3528
Required: true,
@@ -73,10 +66,18 @@ func resourceCloudStackStaticNATCreate(d *schema.ResourceData, meta interface{})
7366
p.SetVmguestip(vmGuestIP.(string))
7467

7568
// Set the network ID based on the guest IP, needed when the public IP address
76-
// is not associated with any network yet (VPC case)
69+
// is not associated with any network yet
70+
NICS:
7771
for _, nic := range vm.Nic {
7872
if vmGuestIP.(string) == nic.Ipaddress {
7973
p.SetNetworkid(nic.Networkid)
74+
break NICS
75+
}
76+
for _, ip := range nic.Secondaryip {
77+
if vmGuestIP.(string) == ip.Ipaddress {
78+
p.SetNetworkid(nic.Networkid)
79+
break NICS
80+
}
8081
}
8182
}
8283
} else {

website/source/docs/providers/cloudstack/r/static_nat.html.markdown

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ The following arguments are supported:
2626
* `ip_address_id` - (Required) The public IP address ID for which static
2727
NAT will be enabled. Changing this forces a new resource to be created.
2828

29-
* `network_id` - (Deprecated) The network ID of the VM the static NAT will be
30-
enabled for. This argument is no longer needed and can be safely omitted.
31-
3229
* `virtual_machine_id` - (Required) The virtual machine ID to enable the
3330
static NAT feature for. Changing this forces a new resource to be created.
3431

0 commit comments

Comments
 (0)