我正在尝试使用 Fog 列出 S3 存储桶的内容,但不断出现错误:
The request signature we calculated does not match the signature you provided. Check your key and signing method.
设置细节
EC2 实例
IAM 角色“S3BucketAccess”:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::*",
"arn:aws:s3:::mybucket/*",
"arn:aws:s3:::mybucket/deploy",
"arn:aws:s3:::mybucket/deploy/*"
]
},
{
"Effect": "Allow",
"Action": "s3:ListAllMyBuckets",
"Resource": "arn:aws:s3:::*"
}
]
}
169.254.169.254/latest/meta-data/iam/security-credentials/S3BucketAccess
{
"Code" : "Success",
"LastUpdated" : "2013-06-28T11:54:08Z",
"Type" : "AWS-HMAC",
"AccessKeyId" : "XXXXXXXXXX",
"SecretAccessKey" : "YYYYYYYYYY",
"Token" : "ALongToken",
"Expiration" : "2013-06-28T18:15:09Z"
}
红宝石代码:
require 'rubygems'
require 'fog'
connection = Fog::Storage::AWS.new({:use_iam_profile => true})
p connection.directories
使用上述错误代码获取令人讨厌的错误消息/堆栈跟踪。