|
7 | 7 | "strings" |
8 | 8 | "time" |
9 | 9 |
|
| 10 | + "github.com/hashicorp/go-cty/cty" |
10 | 11 | "github.com/hashicorp/terraform-plugin-sdk/v2/diag" |
11 | 12 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" |
12 | 13 | "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" |
@@ -198,18 +199,18 @@ func ResourceCluster() *schema.Resource { |
198 | 199 | "private_ips": { |
199 | 200 | Type: schema.TypeList, |
200 | 201 | Computed: true, |
201 | | - Description: "List of private IP addresses associated with the resource", |
| 202 | + Description: "List of private IPv4 addresses associated with the resource", |
202 | 203 | Elem: &schema.Resource{ |
203 | 204 | Schema: map[string]*schema.Schema{ |
204 | 205 | "id": { |
205 | 206 | Type: schema.TypeString, |
206 | 207 | Computed: true, |
207 | | - Description: "The ID of the IP address resource", |
| 208 | + Description: "The ID of the IPv4 address resource", |
208 | 209 | }, |
209 | 210 | "address": { |
210 | 211 | Type: schema.TypeString, |
211 | 212 | Computed: true, |
212 | | - Description: "The private IP address", |
| 213 | + Description: "The private IPv4 address", |
213 | 214 | }, |
214 | 215 | }, |
215 | 216 | }, |
@@ -365,7 +366,8 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac |
365 | 366 | } |
366 | 367 |
|
367 | 368 | // set endpoints |
368 | | - var allPrivateIPs []map[string]interface{} |
| 369 | + allPrivateIPs := []map[string]interface{}(nil) |
| 370 | + diags := diag.Diagnostics{} |
369 | 371 |
|
370 | 372 | pnI, pnExists := flattenPrivateNetwork(cluster.Endpoints) |
371 | 373 | if pnExists { |
@@ -395,7 +397,16 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac |
395 | 397 |
|
396 | 398 | privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts) |
397 | 399 | 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 | + }) |
399 | 410 | } |
400 | 411 |
|
401 | 412 | if privateIPs != nil { |
@@ -426,7 +437,7 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac |
426 | 437 | _ = d.Set("certificate", "") |
427 | 438 | } |
428 | 439 |
|
429 | | - return nil |
| 440 | + return diags |
430 | 441 | } |
431 | 442 |
|
432 | 443 | func ResourceClusterUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { |
|
0 commit comments