diff --git a/.changelog/31757.txt b/.changelog/31757.txt new file mode 100644 index 00000000000..4d3d5618518 --- /dev/null +++ b/.changelog/31757.txt @@ -0,0 +1,3 @@ +```release-note:bug +data/aws_ecr_repository: Correctly set `most_recent_image_tags` when only a single image is found +``` diff --git a/internal/service/ecr/repository_data_source.go b/internal/service/ecr/repository_data_source.go index 8cf604638c8..d886e48dc7d 100644 --- a/internal/service/ecr/repository_data_source.go +++ b/internal/service/ecr/repository_data_source.go @@ -143,7 +143,7 @@ func dataSourceRepositoryRead(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "reading images for ECR Repository (%s): %s", d.Id(), err) } - if len(imageDetails) > 1 { + if len(imageDetails) >= 1 { slices.SortFunc(imageDetails, func(a, b *ecr.ImageDetail) bool { return aws.TimeValue(a.ImagePushedAt).After(aws.TimeValue(b.ImagePushedAt)) })