@@ -88,6 +88,7 @@ func (r *agentRuntimeResource) Schema(ctx context.Context, request resource.Sche
8888 CustomType : fwtypes .MapOfStringType ,
8989 Optional : true ,
9090 },
91+ "lifecycle_configuration" : framework .ResourceOptionalComputedListOfObjectsAttribute [lifecycleConfigurationModel ](ctx , 1 , nil , listplanmodifier .UseStateForUnknown ()),
9192 names .AttrRoleARN : schema.StringAttribute {
9293 CustomType : fwtypes .ARNType ,
9394 Required : true ,
@@ -153,22 +154,6 @@ func (r *agentRuntimeResource) Schema(ctx context.Context, request resource.Sche
153154 },
154155 },
155156 },
156- "lifecycle_configuration" : schema.ListNestedBlock {
157- CustomType : fwtypes.NewListNestedObjectTypeOf [lifecycleConfigurationModel ](ctx ),
158- Validators : []validator.List {
159- listvalidator .SizeAtMost (1 ),
160- },
161- NestedObject : schema.NestedBlockObject {
162- Attributes : map [string ]schema.Attribute {
163- "idle_runtime_session_timeout" : schema.Int32Attribute {
164- Optional : true ,
165- },
166- "max_lifetime" : schema.Int32Attribute {
167- Optional : true ,
168- },
169- },
170- },
171- },
172157 names .AttrNetworkConfiguration : schema.ListNestedBlock {
173158 CustomType : fwtypes.NewListNestedObjectTypeOf [networkConfigurationModel ](ctx ),
174159 Validators : []validator.List {
@@ -286,14 +271,22 @@ func (r *agentRuntimeResource) Create(ctx context.Context, request resource.Crea
286271 return
287272 }
288273
289- // Set values for unknowns.
290- smerr .EnrichAppend (ctx , & response .Diagnostics , fwflex .Flatten (ctx , out , & data , fwflex .WithFieldNamePrefix ("AgentRuntime" )))
291- if response .Diagnostics .HasError () {
274+ agentRuntimeID := aws .ToString (out .AgentRuntimeId )
275+
276+ if _ , err := waitAgentRuntimeCreated (ctx , conn , agentRuntimeID , r .CreateTimeout (ctx , data .Timeouts )); err != nil {
277+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
292278 return
293279 }
294280
295- if _ , err := waitAgentRuntimeCreated (ctx , conn , data .AgentRuntimeID .ValueString (), r .CreateTimeout (ctx , data .Timeouts )); err != nil {
296- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , data .AgentRuntimeName .String ())
281+ runtime , err := findAgentRuntimeByID (ctx , conn , agentRuntimeID )
282+ if err != nil {
283+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
284+ return
285+ }
286+
287+ // Set values for unknowns.
288+ smerr .EnrichAppend (ctx , & response .Diagnostics , fwflex .Flatten (ctx , runtime , & data , fwflex .WithFieldNamePrefix ("AgentRuntime" )))
289+ if response .Diagnostics .HasError () {
297290 return
298291 }
299292
@@ -309,14 +302,15 @@ func (r *agentRuntimeResource) Read(ctx context.Context, request resource.ReadRe
309302
310303 conn := r .Meta ().BedrockAgentCoreClient (ctx )
311304
312- out , err := findAgentRuntimeByID (ctx , conn , data .AgentRuntimeID .ValueString ())
305+ agentRuntimeID := fwflex .StringValueFromFramework (ctx , data .AgentRuntimeID )
306+ out , err := findAgentRuntimeByID (ctx , conn , agentRuntimeID )
313307 if tfresource .NotFound (err ) {
314308 response .Diagnostics .Append (fwdiag .NewResourceNotFoundWarningDiagnostic (err ))
315309 response .State .RemoveResource (ctx )
316310 return
317311 }
318312 if err != nil {
319- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , data . AgentRuntimeID . String () )
313+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
320314 return
321315 }
322316
@@ -345,6 +339,7 @@ func (r *agentRuntimeResource) Update(ctx context.Context, request resource.Upda
345339 }
346340
347341 if diff .HasChanges () {
342+ agentRuntimeID := fwflex .StringValueFromFramework (ctx , new .AgentRuntimeID )
348343 var input bedrockagentcorecontrol.UpdateAgentRuntimeInput
349344 smerr .EnrichAppend (ctx , & response .Diagnostics , fwflex .Expand (ctx , new , & input , fwflex .WithFieldNamePrefix ("AgentRuntime" )))
350345 if response .Diagnostics .HasError () {
@@ -356,7 +351,7 @@ func (r *agentRuntimeResource) Update(ctx context.Context, request resource.Upda
356351
357352 out , err := conn .UpdateAgentRuntime (ctx , & input )
358353 if err != nil {
359- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , new . AgentRuntimeID . String () )
354+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
360355 return
361356 }
362357
@@ -365,8 +360,8 @@ func (r *agentRuntimeResource) Update(ctx context.Context, request resource.Upda
365360 return
366361 }
367362
368- if _ , err := waitAgentRuntimeUpdated (ctx , conn , new . AgentRuntimeID . ValueString () , r .UpdateTimeout (ctx , new .Timeouts )); err != nil {
369- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , new . AgentRuntimeID . String () )
363+ if _ , err := waitAgentRuntimeUpdated (ctx , conn , agentRuntimeID , r .UpdateTimeout (ctx , new .Timeouts )); err != nil {
364+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
370365 return
371366 }
372367 } else {
@@ -385,21 +380,22 @@ func (r *agentRuntimeResource) Delete(ctx context.Context, request resource.Dele
385380
386381 conn := r .Meta ().BedrockAgentCoreClient (ctx )
387382
383+ agentRuntimeID := fwflex .StringValueFromFramework (ctx , data .AgentRuntimeID )
388384 input := bedrockagentcorecontrol.DeleteAgentRuntimeInput {
389- AgentRuntimeId : fwflex . StringFromFramework ( ctx , data . AgentRuntimeID ),
385+ AgentRuntimeId : aws . String ( agentRuntimeID ),
390386 }
391387
392388 _ , err := conn .DeleteAgentRuntime (ctx , & input )
393389 if errs.IsA [* awstypes.ResourceNotFoundException ](err ) {
394390 return
395391 }
396392 if err != nil {
397- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , data . AgentRuntimeID . String () )
393+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
398394 return
399395 }
400396
401- if _ , err := waitAgentRuntimeDeleted (ctx , conn , data . AgentRuntimeID . ValueString () , r .DeleteTimeout (ctx , data .Timeouts )); err != nil {
402- smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , data . AgentRuntimeID . String () )
397+ if _ , err := waitAgentRuntimeDeleted (ctx , conn , agentRuntimeID , r .DeleteTimeout (ctx , data .Timeouts )); err != nil {
398+ smerr .AddError (ctx , & response .Diagnostics , err , smerr .ID , agentRuntimeID )
403399 return
404400 }
405401}
0 commit comments