Last active
May 13, 2021 06:48
-
-
Save MeRahulAhire/b1ee85c0eb4800815a2ce7ed355f7fe3 to your computer and use it in GitHub Desktop.
Get the List of S3 buckets with Encryption enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
const s3 = new AWS.S3(); | |
s3.listBuckets(function(err, data) { | |
if (err) console.log(err, err.stack); | |
let bucketData = data.Buckets; | |
let bucketLength = data.Buckets.length; | |
for (let i = 0; i < bucketLength; i++) { | |
var params = { | |
Bucket: `${bucketData[i].Name}` /* required */ | |
}; | |
s3.getBucketEncryption(params, function(err, data) { | |
try { // first it will print all non encypted buckets and then vice versa | |
if(err){ | |
console.log(bucketData[i].Name) // Non Encrypted Bucket List | |
} | |
if (data) { | |
console.log(bucketData[i].Name); // Encrpted Bucket List | |
} | |
} catch (err) {} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment