66 "fmt"
77 "io"
88
9+ "github.com/hashicorp/go-cty/cty"
910 "github.com/hashicorp/terraform-plugin-log/tflog"
1011 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1112 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -324,10 +325,10 @@ func ResourceInstance() *schema.Resource {
324325 Optional : true ,
325326 Description : "Enable or disable encryption at rest for the database instance" ,
326327 },
327- "private_ips " : {
328+ "private_ip " : {
328329 Type : schema .TypeList ,
329330 Computed : true ,
330- Description : "List of private IPv4 addresses associated with the resource" ,
331+ Description : "The private IPv4 addresses associated with the resource" ,
331332 Elem : & schema.Resource {
332333 Schema : map [string ]* schema.Schema {
333334 "id" : {
@@ -661,7 +662,8 @@ func ResourceRdbInstanceRead(ctx context.Context, d *schema.ResourceData, m inte
661662 _ = d .Set ("logs_policy" , flattenInstanceLogsPolicy (res .LogsPolicy ))
662663
663664 // set endpoints
664- var privateIPs []map [string ]interface {}
665+ privateIPs := make ([]map [string ]interface {}, 0 , 1 )
666+ diags := diag.Diagnostics {}
665667
666668 if pnI , pnExist := flattenPrivateNetwork (res .Endpoints ); pnExist {
667669 _ = d .Set ("private_network" , pnI )
@@ -681,21 +683,30 @@ func ResourceRdbInstanceRead(ctx context.Context, d *schema.ResourceData, m inte
681683
682684 endpointPrivateIPs , err := ipam .GetResourcePrivateIPs (ctx , m , region , opts )
683685 if err != nil {
684- return diag .FromErr (err )
686+ if ! httperrors .Is403 (err ) {
687+ return diag .FromErr (err )
688+ }
689+
690+ diags = append (diags , diag.Diagnostic {
691+ Severity : diag .Warning ,
692+ Summary : err .Error (),
693+ Detail : "Got 403 while reading private IP from IPAM API, please check your IAM permissions" ,
694+ AttributePath : cty .GetAttrPath ("private_ip" ),
695+ })
685696 }
686697
687698 privateIPs = append (privateIPs , endpointPrivateIPs ... )
688699 }
689700 }
690701 }
691702
692- _ = d .Set ("private_ips " , privateIPs )
703+ _ = d .Set ("private_ip " , privateIPs )
693704
694705 if lbI , lbExists := flattenLoadBalancer (res .Endpoints ); lbExists {
695706 _ = d .Set ("load_balancer" , lbI )
696707 }
697708
698- return nil
709+ return diags
699710}
700711
701712//gocyclo:ignore
0 commit comments