Skip to content

Commit

Permalink
Allow graceful inconsistency management by TF when public_ips in reso…
Browse files Browse the repository at this point in the history
…urceOAPINatServiceRead() is empty

In `resourceOAPINatServiceRead()`, access to `public_ips[0]` isn't protected against empty list when the API can return an empty list in some edge cases.
When `public_ips` is empty, setting `public_ip_id` to `""` allows the TF refresh to succeed and the TF plan/apply to recreate the Nat Service with the correct `public_ip_id`.
  • Loading branch information
OursDesCavernes authored and outscale-toa committed Oct 16, 2023
1 parent 811bedc commit 6c1f2ec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions outscale/resource_outscale_nat_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,14 @@ func resourceOAPINatServiceRead(d *schema.ResourceData, meta interface{}) error
return err
}

if err := set("public_ip_id", public_ips[0].GetPublicIpId()); err != nil {
return err
if len(public_ips) > 0 {
if err := set("public_ip_id", public_ips[0].GetPublicIpId()); err != nil {
return err
}
} else {
if err := set("public_ip_id", ""); err != nil {
return err
}
}

if err := d.Set("tags", tagsOSCAPIToMap(natService.GetTags())); err != nil {
Expand Down

0 comments on commit 6c1f2ec

Please sign in to comment.