@@ -73,11 +73,21 @@ func resourceCloudStackPortForward() *schema.Resource {
7373 Required : true ,
7474 },
7575
76+ "private_end_port" : {
77+ Type : schema .TypeInt ,
78+ Optional : true ,
79+ },
80+
7681 "public_port" : {
7782 Type : schema .TypeInt ,
7883 Required : true ,
7984 },
8085
86+ "public_end_port" : {
87+ Type : schema .TypeInt ,
88+ Optional : true ,
89+ },
90+
8191 "virtual_machine_id" : {
8292 Type : schema .TypeString ,
8393 Required : true ,
@@ -175,6 +185,12 @@ func createPortForward(d *schema.ResourceData, meta interface{}, forward map[str
175185 // Create a new parameter struct
176186 p := cs .Firewall .NewCreatePortForwardingRuleParams (d .Id (), forward ["private_port" ].(int ),
177187 forward ["protocol" ].(string ), forward ["public_port" ].(int ), vm .Id )
188+ if forward ["private_end_port" ].(int ) != 0 {
189+ p .SetPrivateendport (forward ["private_end_port" ].(int ))
190+ }
191+ if forward ["public_end_port" ].(int ) != 0 {
192+ p .SetPublicendport (forward ["public_end_port" ].(int ))
193+ }
178194
179195 if vmGuestIP , ok := forward ["vm_guest_ip" ]; ok && vmGuestIP .(string ) != "" {
180196 p .SetVmguestip (vmGuestIP .(string ))
@@ -279,15 +295,31 @@ func resourceCloudStackPortForwardRead(d *schema.ResourceData, meta interface{})
279295 return err
280296 }
281297
298+ privEndPort , err := strconv .Atoi (f .Privateendport )
299+ if err != nil {
300+ return err
301+ }
302+
282303 pubPort , err := strconv .Atoi (f .Publicport )
283304 if err != nil {
284305 return err
285306 }
286307
308+ pubEndPort , err := strconv .Atoi (f .Publicendport )
309+ if err != nil {
310+ return err
311+ }
312+
287313 // Update the values
288314 forward ["protocol" ] = f .Protocol
289315 forward ["private_port" ] = privPort
290316 forward ["public_port" ] = pubPort
317+ if f .Privateendport != "" && f .Privateendport != f .Privateport {
318+ forward ["private_end_port" ] = privEndPort
319+ }
320+ if f .Publicendport != "" && f .Publicendport != f .Publicport {
321+ forward ["public_end_port" ] = pubEndPort
322+ }
291323 forward ["virtual_machine_id" ] = f .Virtualmachineid
292324
293325 // This one is a bit tricky. We only want to update this optional value
0 commit comments