I am attempting to use the AWS SDK to conveniently retrieve data from an S3 bucket without having to provide credentials.
I have a directory of files and I want to be able to add files/remove files/rename files within that directory without having to update my code.
Right now I have just been trying to make sure that I can retrieve the ListObjects, at which point I can parse the response to get the Keys.
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.669.0.min.js"></script>
<reference types="aws-sdk" />
<script>
window.onload = function loadFilenames() {
var s3 = new AWS.S3();
var params = {
Bucket: "bucketname",
Prefix: "fileslocation/"
};
s3.listObjectsV2(params, function(err, data){
if (err) console.log(err, err.stack);
else console.log(data);
});
}
When I do this I get the error: CredentialsError: Missing credentials in config...
Because I want a visitor to the website to be able to see this data, I don't want to have to create an IAM user and pass the credentials. Is there a way to do this, or am I barking up the wrong tree? Thanks!