Skip to content

Commit

Permalink
Merge pull request #32 from vngcloud/iam-vserver
Browse files Browse the repository at this point in the history
fix bug import subnet
  • Loading branch information
manhtu1997 authored Nov 15, 2024
2 parents 08b50fc + 9b69dfe commit f9cd912
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions resource/vserver/resource_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ func ResourceSubnet() *schema.Resource {
Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
idParts := strings.Split(d.Id(), ":")
if len(idParts) != 2 || idParts[0] == "" || idParts[1] == "" {
return nil, fmt.Errorf("Unexpected format of ID (%q), expected ProjectID:SubnetID", d.Id())
if len(idParts) != 3 || idParts[0] == "" || idParts[1] == "" || idParts[2] == "" {
return nil, fmt.Errorf("Unexpected format of ID (%q), expected ProjectID:NetworkID:SubnetID", d.Id())
}
projectID := idParts[0]
subnetID := idParts[1]
networkID := idParts[1]
subnetID := idParts[2]
d.SetId(subnetID)
d.Set("project_id", projectID)
d.Set("network_id", networkID)
return []*schema.ResourceData{d}, nil
},
},
Expand Down

0 comments on commit f9cd912

Please sign in to comment.