Skip to content

Commit 573f2f9

Browse files
committed
findInstance: Use 'tfslices.CollectWithError'.
1 parent b49717f commit 573f2f9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

internal/service/ec2/find.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,10 @@ func findInstanceByID(ctx context.Context, conn *ec2.Client, id string) (*awstyp
409409
}
410410

411411
func findInstance(ctx context.Context, conn *ec2.Client, input *ec2.DescribeInstancesInput) (*awstypes.Instance, error) {
412-
var output []awstypes.Instance
413-
for v, err := range listInstances(ctx, conn, input) {
414-
if err != nil {
415-
return nil, err
416-
}
417-
output = append(output, v)
412+
output, err := tfslices.CollectWithError(listInstances(ctx, conn, input))
413+
414+
if err != nil {
415+
return nil, err
418416
}
419417

420418
return tfresource.AssertSingleValueResult(output, func(v *awstypes.Instance) bool { return v.State != nil })

0 commit comments

Comments
 (0)