8
votes

I have tried googling how I could retrieve a list of available s3 buckets associated with an Amazon Access Key, but either I am searching the wrong terms, or I haven't went through enough results.

I have an access key and secret key, but I do not know the bucket name(s) associated with either the account or IAM user.

How can I get a list of the bucket names available using Powershell and AWS Tools?

1
What information specifically are you looking for? Buckets that are visible to that credential holder, or buckets that credential holder is responsible for?Anthony Neace
Hi Anthony, I am looking for buckets that are 'visible' and accessible to user associated with access/secret key. Thanks!Jim P.

1 Answers

13
votes

Assuming that you've already set up your AWS Credentials the way you want, you can simply call Get-S3Bucket. This invokes ListBuckets, and returns a collection of S3Bucket objects that are visible to you:

Example:

# With credentials stored in the SDK store:
PS C:\> Get-S3Bucket

CreationDate                                                BucketName
------------                                                ----------
5/20/2015 2:00:00 PM                                        MyBucket1
5/21/2015 4:00:00 PM                                        MyBucket2

 # With credentials passed inline:    
PS C:\> Get-S3Bucket -AccessKey "accKey" -SecretKey "secKey" -Region "us-east-1"

CreationDate                                                BucketName
------------                                                ----------
5/20/2015 2:00:00 PM                                        MyBucket1
5/21/2015 4:00:00 PM                                        MyBucket2