0
我有以下S3结构:读AWS政策/写文件的内斗
桶名称:测试斗
文件:test.json
和我有以下AWS政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:PutObject",
"Action": "s3:GetObject",
"Action": "s3:DeleteObject",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::test-bucket"
}
]
}
,这一政策被连接到用户与访问密钥123
当我尝试使用SDK,因为这在测试桶放或获取test.json:
BasicAWSCredentials awsCreds = new BasicAWSCredentials("123", "secretKeyId");
s3Client = AmazonS3ClientBuilder.standard()
.withCredentials(new AWSStaticCredentialsProvider(awsCreds))
.withRegion("US-EAST-1")
.build();
s3Client.putObject(new PutObjectRequest("test-bucket", "test.json", file));
这将给访问拒绝的问题。
如果我改变策略的资源
"Resource": "*"
那么它会工作。我只是想确保我放入的资源格式正确。什么地方出了错?
错字:'ListBucekt' - >'ListBucket' – Jeremy
@Jeremy哦,那是复制粘贴在错字。 – jamesdeath123