Created
February 10, 2020 18:40
-
-
Save micahhausler/7b276124cd4e70ae28dca36a36756cbf to your computer and use it in GitHub Desktop.
amazon-eks-pod-identity-webhook-issue-34
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
FROM php:alpine | |
RUN apk -U add composer && \ | |
composer require aws/aws-sdk-php | |
ADD ./script.php /opt/code/script.php | |
CMD php /opt/code/script.php |
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
<?php | |
require 'vendor/autoload.php'; | |
use Aws\S3\S3Client; | |
use Aws\Exception\AwsException; | |
use Aws\Credentials\CredentialProvider; | |
$provider = CredentialProvider::assumeRoleWithWebIdentityCredentialProvider(); | |
// Cache the results in a memoize function to avoid loading and parsing | |
// the ini file on every API operation | |
$provider = CredentialProvider::memoize($provider); | |
//Create a S3Client | |
$s3Client = new S3Client([ | |
//'profile' => 'default', | |
'region' => 'us-west-2', | |
'version' => '2006-03-01', | |
'credentials' => $provider | |
]); | |
//Sleep for 7m55s after starting, token rotation is at 8m | |
for ($x = 0; $x <= 5; $x++) { | |
for ($x = 0; $x < 7; $x++) { | |
// Sleep for a minute | |
$date = date('Y-m-d H:i:s'); | |
echo $date . " Sleeping 1 minute, " . 7 - $x . "min left\n"; | |
sleep(60); | |
} | |
$date = date('Y-m-d H:i:s'); | |
echo $date . " Sleeping 55 seconds\n"; | |
sleep(55); | |
for ($x = 0; $x <= 2; $x++) { | |
//Listing all S3 Bucket | |
$buckets = $s3Client->listBuckets(); | |
foreach ($buckets['Buckets'] as $bucket) { | |
echo " " . $bucket['Name'] . "\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment