aws-sdk-go-v2
aws-sdk-go-v2 copied to clipboard
s3manager.BatchDelete missing from SDK V2
- [x] I've gone though the API reference
- [x] I've checked AWS Forums and StackOverflow for answers
- [x] I've searched for previous similar issues and didn't find any solution
Description
Handy abstractions like service/s3/s3manager.BatchDelete seem to have disappeared in the second version of the SDK. Unless I missed some obvious fact, emptying an AWS S3 bucket requires much more code with V2 than with V1 iterators, to the point of requiring developers to build by hands a ObjectIdentifier slice.
SDK version
1.9.2
Go version
go version go1.17.1 darwin/amd64
Observed behavior
paginator := s3.NewListObjectsV2Paginator(client, &s3.ListObjectsV2Input{
Bucket: aws.String(bucket),
})
for paginator.HasMorePages() {
page, err := paginator.NextPage(ctx)
if err != nil {
return err
}
var objects []types.ObjectIdentifier
for _, object := range page.Contents {
objects = append(objects, types.ObjectIdentifier{
Key: object.Key,
})
}
_, err = client.DeleteObjects(ctx, &s3.DeleteObjectsInput{
Bucket: aws.String(bucket),
Delete: &types.Delete{
Objects: objects,
},
})
if err != nil {
return err
}
}
Expected behavior
iterator := s3manager.NewDeleteListIterator(client, &s3.ListObjectsInput{
Bucket: aws.String(bucket),
})
if err := s3manager.NewBatchDeleteWithClient(client).Delete(ctx, iterator); err != nil {
return err
}
Hi @0x2b3bfa0 , Yea this is not included in the V2 of the SDK, they were removed basically because we were not really happy with them and did not want them to carry over into V2, but we are planning on eventually having them added back in some way, it's just been low priority on our backlog. For now though, yea the way to do it is to iterate "manually"
This is an important feature to me.. I hope AWS SDK team can add it back sooner.