Copilot commented on code in PR #305:
URL: 
https://github.com/apache/cloudstack-terraform-provider/pull/305#discussion_r3642564502


##########
cloudstack/resource_cloudstack_port_forward.go:
##########
@@ -230,6 +233,89 @@ func createPortForward(d *schema.ResourceData, meta 
interface{}, forward map[str
        return nil
 }
 
+func resourceCloudStackPortForwardImport(d *schema.ResourceData, meta 
interface{}) ([]*schema.ResourceData, error) {
+       cs := meta.(*cloudstack.CloudStackClient)
+
+       // Try to split the ID to extract the optional project name.
+       s := strings.SplitN(d.Id(), "/", 2)
+       if len(s) == 2 {
+               d.Set("project", s[0])
+       }
+
+       ipAddressID := s[len(s)-1]
+       d.SetId(ipAddressID)
+

Review Comment:
   The importer sets the resource ID to the IP address ID, but it never sets 
the required `ip_address_id` attribute. Since `Read` also never sets 
`ip_address_id`, imported state can end up missing this required attribute and 
cause perpetual diffs or unexpected replacement planning.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to