Skip to content

Commit bbac384

Browse files
committed
updated wording + handle 403 on ipam
1 parent 9d3e8c7 commit bbac384

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

docs/resources/redis_cluster.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ the form `{zone}/{id}`, e.g. `fr-par-1/11111111-1111-1111-1111-111111111111`
195195
- `endpoint_id` - The ID of the endpoint.
196196
- `zone` - The zone of the Private Network.
197197

198-
- `private_ip` - The list of private IPv4 addresses associated with the resource.
198+
- `private_ips` - The list of private IPv4 addresses associated with the resource.
199199
- `id` - The ID of the IPv4 address resource.
200200
- `address` - The private IPv4 address.
201201

internal/services/redis/cluster.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/hashicorp/go-cty/cty"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1112
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
1213
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -198,18 +199,18 @@ func ResourceCluster() *schema.Resource {
198199
"private_ips": {
199200
Type: schema.TypeList,
200201
Computed: true,
201-
Description: "List of private IP addresses associated with the resource",
202+
Description: "List of private IPv4 addresses associated with the resource",
202203
Elem: &schema.Resource{
203204
Schema: map[string]*schema.Schema{
204205
"id": {
205206
Type: schema.TypeString,
206207
Computed: true,
207-
Description: "The ID of the IP address resource",
208+
Description: "The ID of the IPv4 address resource",
208209
},
209210
"address": {
210211
Type: schema.TypeString,
211212
Computed: true,
212-
Description: "The private IP address",
213+
Description: "The private IPv4 address",
213214
},
214215
},
215216
},
@@ -365,7 +366,8 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
365366
}
366367

367368
// set endpoints
368-
var allPrivateIPs []map[string]interface{}
369+
allPrivateIPs := []map[string]interface{}(nil)
370+
diags := diag.Diagnostics{}
369371

370372
pnI, pnExists := flattenPrivateNetwork(cluster.Endpoints)
371373
if pnExists {
@@ -395,7 +397,16 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
395397

396398
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
397399
if err != nil {
398-
return diag.FromErr(err)
400+
if !httperrors.Is403(err) {
401+
return diag.FromErr(err)
402+
}
403+
404+
diags = append(diags, diag.Diagnostic{
405+
Severity: diag.Warning,
406+
Summary: err.Error(),
407+
Detail: "Got 403 while reading private IP from IPAM API, please check your IAM permissions",
408+
AttributePath: cty.GetAttrPath("private_ips"),
409+
})
399410
}
400411

401412
if privateIPs != nil {
@@ -426,7 +437,7 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
426437
_ = d.Set("certificate", "")
427438
}
428439

429-
return nil
440+
return diags
430441
}
431442

432443
func ResourceClusterUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {

0 commit comments

Comments
 (0)