lundi 27 avril 2015

How to list AWS S3 buckets using amazon-javascript-sdk?

I need to get a list of buckets having the client accessKeyId and secretAccessKey. From the docs I understood that I have to update de configurations of AWS, create a new S3 object, then call on it the listBuckets() function with the callback.

So, here's my code:

AWS.config.update({
        accessKeyId: awsKey.identifier, secretAccessKey: awsKey.secret, region: awsKey.region,
        apiVersion: '2006-03-01'
    });

let s3 = new AWS.S3();
s3.listBuckets((response, data) => {
    console.log(response);
    console.log(data);
});

The problem is that I get: enter image description here

Thanks for your attention




Aucun commentaire:

Enregistrer un commentaire