@@ -5,6 +5,8 @@ package odb
55import (
66 "context"
77 "errors"
8+ "github.com/aws/aws-sdk-go-v2/aws"
9+ "github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
810 "strings"
911 "time"
1012
@@ -111,6 +113,7 @@ func (r *resourceNetworkPeeringConnection) Schema(ctx context.Context, req resou
111113 names .AttrCreatedAt : schema.StringAttribute {
112114 Description : "Created time of the odb network peering connection." ,
113115 Computed : true ,
116+ CustomType : timetypes.RFC3339Type {},
114117 },
115118 "percent_progress" : schema.Float32Attribute {
116119 Description : "Progress of the odb network peering connection." ,
@@ -163,15 +166,34 @@ func (r *resourceNetworkPeeringConnection) Create(ctx context.Context, req resou
163166 }
164167 createTimeout := r .CreateTimeout (ctx , plan .Timeouts )
165168 createdPeeredConnection , err := waitNetworkPeeringConnectionCreated (ctx , conn , plan .OdbPeeringConnectionId .ValueString (), createTimeout )
169+ resp .Diagnostics .Append (resp .State .SetAttribute (ctx , path .Root (names .AttrID ), aws .ToString (out .OdbPeeringConnectionId ))... )
166170 if err != nil {
167171 resp .Diagnostics .AddError (
168172 create .ProblemStandardMessage (names .ODB , create .ErrActionWaitingForCreation , ResNameNetworkPeeringConnection , plan .DisplayName .ValueString (), err ),
169173 err .Error (),
170174 )
171175 return
172176 }
173- plan .CreatedAt = types .StringValue (createdPeeredConnection .CreatedAt .Format (time .RFC3339 ))
174- resp .Diagnostics .Append (flex .Flatten (ctx , createdPeeredConnection , & plan , flex .WithIgnoredFieldNamesAppend ("CreatedAt" ))... )
177+
178+ odbNetworkARNParsed , err := arn .Parse (* createdPeeredConnection .OdbNetworkArn )
179+ if err != nil {
180+ resp .Diagnostics .AddError (
181+ create .ProblemStandardMessage (names .ODB , create .ErrActionReading , ResNameNetworkPeeringConnection , plan .DisplayName .ValueString (), err ),
182+ err .Error (),
183+ )
184+ return
185+ }
186+ peerVpcARN , err := arn .Parse (* createdPeeredConnection .PeerNetworkArn )
187+ if err != nil {
188+ resp .Diagnostics .AddError (
189+ create .ProblemStandardMessage (names .ODB , create .ErrActionReading , ResNameNetworkPeeringConnection , plan .DisplayName .ValueString (), err ),
190+ err .Error (),
191+ )
192+ return
193+ }
194+ plan .PeerNetworkId = types .StringValue (strings .Split (peerVpcARN .Resource , "/" )[1 ])
195+ plan .OdbNetworkId = types .StringValue (strings .Split (odbNetworkARNParsed .Resource , "/" )[1 ])
196+ resp .Diagnostics .Append (flex .Flatten (ctx , createdPeeredConnection , & plan )... )
175197 if resp .Diagnostics .HasError () {
176198 return
177199 }
@@ -218,11 +240,9 @@ func (r *resourceNetworkPeeringConnection) Read(ctx context.Context, req resourc
218240 return
219241 }
220242 state .PeerNetworkId = types .StringValue (strings .Split (peerVpcARN .Resource , "/" )[1 ])
221- state .CreatedAt = types .StringValue (out .CreatedAt .Format (time .RFC3339 ))
222243 state .OdbNetworkId = types .StringValue (strings .Split (odbNetworkARNParsed .Resource , "/" )[1 ])
223244
224- resp .Diagnostics .Append (flex .Flatten (ctx , out , & state , flex .WithIgnoredFieldNamesAppend ("CreatedAt" ),
225- flex .WithIgnoredFieldNamesAppend ("PeerNetworkId" ), flex .WithIgnoredFieldNamesAppend ("OdbNetworkId" ))... )
245+ resp .Diagnostics .Append (flex .Flatten (ctx , out , & state )... )
226246 if resp .Diagnostics .HasError () {
227247 return
228248 }
@@ -263,10 +283,8 @@ func (r *resourceNetworkPeeringConnection) Update(ctx context.Context, req resou
263283 return
264284 }
265285 state .PeerNetworkId = types .StringValue (strings .Split (peerVpcARN .Resource , "/" )[1 ])
266- state .CreatedAt = types .StringValue (updatedOdbNetPeeringConn .CreatedAt .Format (time .RFC3339 ))
267286 state .OdbNetworkId = types .StringValue (strings .Split (odbNetworkARNParsed .Resource , "/" )[1 ])
268- resp .Diagnostics .Append (flex .Flatten (ctx , updatedOdbNetPeeringConn , & plan , flex .WithIgnoredFieldNamesAppend ("CreatedAt" ), flex .WithIgnoredFieldNamesAppend ("CreatedAt" ),
269- flex .WithIgnoredFieldNamesAppend ("PeerNetworkId" ), flex .WithIgnoredFieldNamesAppend ("OdbNetworkId" ))... )
287+ resp .Diagnostics .Append (flex .Flatten (ctx , updatedOdbNetPeeringConn , & plan )... )
270288 if resp .Diagnostics .HasError () {
271289 return
272290 }
@@ -401,8 +419,8 @@ func findNetworkPeeringConnectionByID(ctx context.Context, conn *odb.Client, id
401419
402420type odbNetworkPeeringConnectionResourceModel struct {
403421 framework.WithRegionModel
404- OdbNetworkId types.String `tfsdk:"odb_network_id"`
405- PeerNetworkId types.String `tfsdk:"peer_network_id"`
422+ OdbNetworkId types.String `tfsdk:"odb_network_id" autoflex:",noflatten" `
423+ PeerNetworkId types.String `tfsdk:"peer_network_id" autoflex:",noflatten" `
406424 OdbPeeringConnectionId types.String `tfsdk:"id"`
407425 DisplayName types.String `tfsdk:"display_name"`
408426 Status fwtypes.StringEnum [odbtypes.ResourceStatus ] `tfsdk:"status"`
@@ -411,7 +429,7 @@ type odbNetworkPeeringConnectionResourceModel struct {
411429 OdbNetworkArn types.String `tfsdk:"odb_network_arn"`
412430 PeerNetworkArn types.String `tfsdk:"peer_network_arn"`
413431 OdbPeeringConnectionType types.String `tfsdk:"odb_peering_connection_type"`
414- CreatedAt types. String `tfsdk:"created_at"`
432+ CreatedAt timetypes. RFC3339 `tfsdk:"created_at"`
415433 PercentProgress types.Float32 `tfsdk:"percent_progress"`
416434 Timeouts timeouts.Value `tfsdk:"timeouts"`
417435 Tags tftags.Map `tfsdk:"tags"`
0 commit comments