简体   繁体   中英

Block a certain aws s3 Bucket request

I want to have access to the files which are in my s3 buket. However this should only work if I have the link + filename. Currently I can list all files in my buket with the "s3.listObjects" method.

Is it possible to block this certain request?

AWS.config.region = 'location';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
    IdentityPoolId: 'location:xxxxxxxxxx',
});
var s3 = new AWS.S3({
    apiVersion: '2006-03-01',
    params: { Bucket: "buketname" }
});

function listBucketFiles() {
    s3.listObjects({ Delimiter: '/' }, function (err, data) {
        if (err) {
            return alert('There was an error listing your albums: ' + err.message);
        } else {
            console.log(data);

        }
    });
}

You can block the s3:listObjects action by either removing it (or adding explicit Deny ) in the IAM user policies in your AWS account, or by adding a Deny in the S3 bucket policy .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM