@@ -287,6 +287,22 @@ func resourceContainerRecipe() *schema.Resource {
287287 ForceNew : true ,
288288 ValidateFunc : validation .StringLenBetween (1 , 1024 ),
289289 },
290+ "latest_version_arn" : {
291+ Type : schema .TypeString ,
292+ Computed : true ,
293+ },
294+ "latest_major_version_arn" : {
295+ Type : schema .TypeString ,
296+ Computed : true ,
297+ },
298+ "latest_minor_version_arn" : {
299+ Type : schema .TypeString ,
300+ Computed : true ,
301+ },
302+ "latest_patch_version_arn" : {
303+ Type : schema .TypeString ,
304+ Computed : true ,
305+ },
290306 },
291307 }
292308}
@@ -360,14 +376,21 @@ func resourceContainerRecipeCreate(ctx context.Context, d *schema.ResourceData,
360376
361377 d .SetId (aws .ToString (output .ContainerRecipeArn ))
362378
379+ if output .LatestVersionReferences != nil {
380+ d .Set ("latest_version_arn" , aws .ToString (output .LatestVersionReferences .LatestVersionArn ))
381+ d .Set ("latest_major_version_arn" , aws .ToString (output .LatestVersionReferences .LatestMajorVersionArn ))
382+ d .Set ("latest_minor_version_arn" , aws .ToString (output .LatestVersionReferences .LatestMinorVersionArn ))
383+ d .Set ("latest_patch_version_arn" , aws .ToString (output .LatestVersionReferences .LatestPatchVersionArn ))
384+ }
385+
363386 return append (diags , resourceContainerRecipeRead (ctx , d , meta )... )
364387}
365388
366389func resourceContainerRecipeRead (ctx context.Context , d * schema.ResourceData , meta any ) diag.Diagnostics {
367390 var diags diag.Diagnostics
368391 conn := meta .(* conns.AWSClient ).ImageBuilderClient (ctx )
369392
370- containerRecipe , err := findContainerRecipeByARN (ctx , conn , d .Id ())
393+ output , err := findContainerRecipeByARN (ctx , conn , d .Id ())
371394
372395 if ! d .IsNewResource () && tfresource .NotFound (err ) {
373396 log .Printf ("[WARN] Image Builder Container Recipe (%s) not found, removing from state" , d .Id ())
@@ -379,6 +402,8 @@ func resourceContainerRecipeRead(ctx context.Context, d *schema.ResourceData, me
379402 return sdkdiag .AppendErrorf (diags , "reading Image Builder Container Recipe (%s): %s" , d .Id (), err )
380403 }
381404
405+ containerRecipe := output .ContainerRecipe
406+
382407 d .Set (names .AttrARN , containerRecipe .Arn )
383408 if err := d .Set ("component" , flattenComponentConfigurations (containerRecipe .Components )); err != nil {
384409 return sdkdiag .AppendErrorf (diags , "setting component: %s" , err )
@@ -406,6 +431,13 @@ func resourceContainerRecipeRead(ctx context.Context, d *schema.ResourceData, me
406431 d .Set (names .AttrVersion , containerRecipe .Version )
407432 d .Set ("working_directory" , containerRecipe .WorkingDirectory )
408433
434+ if output .LatestVersionReferences != nil {
435+ d .Set ("latest_version_arn" , aws .ToString (output .LatestVersionReferences .LatestVersionArn ))
436+ d .Set ("latest_major_version_arn" , aws .ToString (output .LatestVersionReferences .LatestMajorVersionArn ))
437+ d .Set ("latest_minor_version_arn" , aws .ToString (output .LatestVersionReferences .LatestMinorVersionArn ))
438+ d .Set ("latest_patch_version_arn" , aws .ToString (output .LatestVersionReferences .LatestPatchVersionArn ))
439+ }
440+
409441 setTagsOut (ctx , containerRecipe .Tags )
410442
411443 return diags
@@ -439,7 +471,7 @@ func resourceContainerRecipeDelete(ctx context.Context, d *schema.ResourceData,
439471 return diags
440472}
441473
442- func findContainerRecipeByARN (ctx context.Context , conn * imagebuilder.Client , arn string ) (* awstypes. ContainerRecipe , error ) {
474+ func findContainerRecipeByARN (ctx context.Context , conn * imagebuilder.Client , arn string ) (* imagebuilder. GetContainerRecipeOutput , error ) {
443475 input := & imagebuilder.GetContainerRecipeInput {
444476 ContainerRecipeArn : aws .String (arn ),
445477 }
@@ -461,7 +493,7 @@ func findContainerRecipeByARN(ctx context.Context, conn *imagebuilder.Client, ar
461493 return nil , tfresource .NewEmptyResultError (input )
462494 }
463495
464- return output . ContainerRecipe , nil
496+ return output , nil
465497}
466498
467499func expandInstanceConfiguration (tfMap map [string ]any ) * awstypes.InstanceConfiguration {
0 commit comments