I am trying to list all the items inside an S3 storage bucket. I have made my bucket public and my storage type is also set to guest but still when I run the Amplify.Storage.list()
method it throws an access denied error (403)
Here's the code:
Future<void> listItems() async {
try {
final ListResult result = await Amplify.Storage.list();
final List<StorageItem> items = result.items;
print('Got items: $items');
} on StorageException catch (e) {
print('Error listing items: $e');
}
}
What am I missing?
For me, the fix was to add the
s3:ListBucket
action to the policy. Here is my CDK implementation (mostly from a tutorial).