Skip to content

Instantly share code, notes, and snippets.

@mrw
Last active July 2, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrw/839e2524503081ee9d45 to your computer and use it in GitHub Desktop.
Save mrw/839e2524503081ee9d45 to your computer and use it in GitHub Desktop.
Enable MFA Delete on S3 Buckets
<?php
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
$s3 = new S3Client([
'region' => 'us-east-1',
'version' => 'latest',
'credentials' => [
'key' => '',
'secret' => '',
]
]);
$result = $s3->listBuckets();
foreach ($result['Buckets'] as $bucket) {
print_r($bucket);
try {
print_r($s3->getBucketVersioning(array(
'Bucket' => $bucket['Name'])
));
} catch (Exception $e) {
continue;
}
echo "<hr>";
}
// $result = $s3->putBucketVersioning([
// 'Bucket' => 'vector-vault',
// 'MFA' => 'MFADeviceARN OTPCode',
// 'VersioningConfiguration' => [
// 'MFADelete' => 'Enabled',
// 'Status' => 'Enabled',
// ],
// ]);
var_dump($result);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment