amazon-web-services - 如何合并 AWS S3 存储桶策略?
问题描述
我们在生产中有一个现有的 S3 存储桶策略:
{
"Version": "2012-10-17",
"Id": "Policy[redacted]",
"Statement": [
{
"Sid": "ServiceA access",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[redacted]:root"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::mysite-production/*"
},
{
"Sid": "ServiceA access",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::[redacted]:root"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::mysite-production"
},
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::mysite-production/*"
}
]
}
我们要授予访问权限的另一个 3rd 方服务需要:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
},
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Resource": "arn:aws:s3:::*"
}
]
}
我已经尝试将ListAllMyBuckets
and合并GetBucketLocation
到我们原始政策的最后一部分,但会产生“政策无效行动”错误:
{
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": [
"s3:GetObject",
"s3:PutObject",
"s3:PutObjectAcl",
"s3:DeleteObject"
],
"Resource": "arn:aws:s3:::mysite-production/*"
}
我怎样才能将这些合并成一个有凝聚力的政策?或者一个桶是否有可能有两个策略?
提前致谢!
解决方案
您实际上可以同时应用 IAM 策略和 S3 存储桶策略 ,最终授权是所有权限的最低权限联合。
推荐阅读
- python - 如何使用 Zelle 的 graphics.py 在窗口中分层 GraphicsObjects?
- flutter - Flutter - 触发另一个小部件方法哪个小部件在另一个文件中
- http - rustls HTTP 请求响应 301
- javascript - 如何在没有内联脚本的情况下实现 google reCaptcha?
- flutter - 如何为平板电脑设置横向?
- css - 为什么这种媒体查询样式应用低于其指定阈值?
- nat - NAT 错误 1002 后面的蓝色大按钮服务器
- reactjs - 如何修复绑定元素“post”隐式具有“any”类型.ts(7031)
- javascript - 将 showPrintMargin 设置为 false 在 React Ace 编辑器中不起作用
- c++ - c++ 如何在没有显式创建可迭代容器的情况下迭代对象集合