使用PowerShell获取与amazon访问密钥相关的s3存储桶列表?

Jim*_* P. 6 powershell amazon-s3 amazon-web-services aws-powershell

我已经尝试使用谷歌搜索如何检索与亚马逊访问密钥相关的可用s3存储桶列表,但要么我正在搜索错误的条款,要么我没有通过足够的结果.

我有一个访问密钥和密钥,但我不知道与帐户或IAM用户关联的存储桶名称.

如何使用Powershell和AWS Tools获取可用的存储桶名称列表?

Ant*_*ace 10

假设您已经按照自己的方式设置了您的AWS凭证,您只需调用Get-S3Bucket即可.这会调用ListBuckets,并返回一组对您可见的S3Bucket对象:

例:

# 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
Run Code Online (Sandbox Code Playgroud)