8

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?

Anthony Neace
  • 25,013
  • 7
  • 114
  • 129
Jim P.
  • 1,087
  • 3
  • 9
  • 24
  • 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 May 21 '15 at 19:35
  • Hi Anthony, I am looking for buckets that are 'visible' and accessible to user associated with access/secret key. Thanks! – Jim P. May 21 '15 at 19:40

1 Answers1

13

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
Anthony Neace
  • 25,013
  • 7
  • 114
  • 129
  • Beautifully simple! Thank you for the succinct informative response. This is exactly what I was looking and hoping for! – Jim P. May 21 '15 at 20:09