func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) // Get the network ACL list details f, count, err := cs.NetworkACL.GetNetworkACLListByID( d.Id(), cloudstack.WithVPCID(d.Get("vpc_id").(string)), ) if err != nil { if count == 0 { log.Printf( "[DEBUG] Network ACL list %s does no longer exist", d.Get("name").(string)) d.SetId("") return nil } return err } d.Set("name", f.Name) d.Set("description", f.Description) d.Set("vpc_id", f.Vpcid) return nil }
func resourceCloudStackNetworkACLRead(d *schema.ResourceData, meta interface{}) error { cs := meta.(*cloudstack.CloudStackClient) vpc, ok := d.GetOk("vpc_id") if !ok { vpc, ok = d.GetOk("vpc") } if !ok { return errors.New("Either `vpc_id` or [deprecated] `vpc` must be provided.") } // Retrieve the vpc ID vpcid, e := retrieveID(cs, "vpc", vpc.(string)) if e != nil { return e.Error() } // Get the network ACL list details f, count, err := cs.NetworkACL.GetNetworkACLListByID(d.Id(), cloudstack.WithVPCID(vpcid)) if err != nil { if count == 0 { log.Printf( "[DEBUG] Network ACL list %s does no longer exist", d.Get("name").(string)) d.SetId("") return nil } return err } d.Set("name", f.Name) d.Set("description", f.Description) d.Set("vpc_id", f.Vpcid) return nil }