目标是将 Amazon S3 读写(列表、获取、放置、删除)访问限制为单个角色,并且仅通过访问点访问 S3,存储桶策略仅锁定到访问点。
到目前为止我所做的设置是
- 将 s3 的部分(列表、获取、放置、删除)访问控制委托给访问点。
- 在访问点级别应用显式拒绝以限制仅对一个角色的访问。
- 在该角色中添加了一个策略,允许它通过访问点列出、获取、放置、删除。
但有AccessDenied
上述任何操作的经验
这是 S3 存储桶策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AuthorizeS3ObjectsReadModifyThroughAccessPointsOnly",
"Effect": "Deny",
"Principal": "*",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::XXX-YYY-ZZZ/*",
"Condition": {
"ForAllValues:StringNotEquals": {
"s3:DataAccessPointArn": "arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ"
}
}
},
{
"Sid": "AuthorizeS3ObjectsListThroughAccessPointsOnly",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::XXX-YYY-ZZZ",
"Condition": {
"ForAllValues:StringNotEquals": {
"s3:DataAccessPointArn": "arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ"
}
}
}
]
}
这是接入点策略:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AuthorizeReadModifyS3ObjectsThroughSpecificRoleOnly",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ/object/*",
"Condition": {
"ForAllValues:StringNotEquals": {
"aws:PrincipalArn": "arn:aws:iam::XXX-YYY-ZZZ:role/XXX-YYY-ZZZ"
}
}
},
{
"Sid": "AuthorizeListS3ObjectsThroughSpecificRoleOnly",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ",
"Condition": {
"ForAllValues:StringNotEquals": {
"aws:PrincipalArn": "arn:aws:iam::XXX-YYY-ZZZ:role/XXX-YYY-ZZZ"
}
}
}
]
}
这是角色政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ReadModifyS3Objects",
"Effect": "Allow",
"Action": [
"s3:DeleteObject",
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ/object/*",
]
},
{
"Sid": "ListS3Objects",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ"
]
}
]
}
这不起作用 - AccessDenied
。我正在使用假设的适当角色进行测试,例如使用此命令aws s3 ls "s3://arn:aws:s3:us-east-1:XXX-YYY-ZZZ:accesspoint/XXX-YYY-ZZZ/"
奇怪的是,如果角色策略资源使用 S3 存储桶 ARN(如arn:aws:s3:::XXX-YYY-ZZZ/*
和arn:aws:s3:::XXX-YYY-ZZZ
)扩展,因此访问和 s3 存储桶资源都存在,则允许访问。如果删除任何accesspoint
资源会使该资源AccessDenied
再次出现。无法理解这一点,似乎我缺少一些基本的东西,非常感谢文档或解决方案/建议中的任何指针。