I need to get list of objects from my AWS s3 bucket. I try:
const s3 = new AWS.S3();
const params = {
Bucket: "arn:aws:s3:::test-bucket-n-i",
MaxKeys: 10
};
s3.listObjectsV2(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
This Arn I copied form my test bucket. As result I get:
InvalidARN: ARN accountID does not match regex "[0-9]{12}"
How can it be invalid? How can I call s3.listObjectsV2 without creating an Access point?
CodePudding user response:
If you are using
Bucket: "arn:aws:s3:::test-bucket-n-i",
it means that you are using S3 Access points. Access points are account specific, and the given ARN is invalid access point ARN.
If you don't use access points, then you just provide bucket name:
Bucket: "test-bucket-n-i",