Skip to content

Commit

Permalink
Fix route ressource id and test
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericBerot-Armand authored and outscale-toa committed Dec 8, 2022
1 parent 58e899a commit 9d27ae7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions outscale/resource_outscale_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,15 @@ func resourceOutscaleOAPIRouteCreate(d *schema.ResourceData, meta interface{}) e
}
}

d.SetId(d.Get("route_table_id").(string))
d.SetId(d.Get("route_table_id").(string) + "_" + d.Get("destination_ip_range").(string))

resourceOutscaleOAPIRouteSetResourceData(d, route, requestID)
return nil
}

func resourceOutscaleOAPIRouteRead(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*OutscaleClient).OSCAPI
routeTableID := d.Id()
routeTableID := d.Get("route_table_id").(string)

destinationIPRange := d.Get("destination_ip_range").(string)
var requestID string
Expand Down Expand Up @@ -499,7 +500,7 @@ func resourceOutscaleOAPIRouteImportState(d *schema.ResourceData, meta interface
return nil, fmt.Errorf("error setting `%s` for Outscale Route(%s): %s", "destination_ip_range", destinationIPRange, err)
}

d.SetId(routeTableID)
d.SetId(d.Get("route_table_id").(string) + "_" + d.Get("destination_ip_range").(string))

return []*schema.ResourceData{d}, nil
}
2 changes: 1 addition & 1 deletion outscale/resource_outscale_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func testAccCheckOutscaleOAPIRouteImportStateIDFunc(resourceName string) resourc
if !ok {
return "", fmt.Errorf("Not found: %s", resourceName)
}
return fmt.Sprintf("%s_%s", rs.Primary.ID, rs.Primary.Attributes["destination_ip_range"]), nil
return rs.Primary.ID, nil
}
}

Expand Down

0 comments on commit 9d27ae7

Please sign in to comment.