amazon-s3 - IAM 政策未授予访问点的访问权限
问题描述
有了这个政策:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListStorageLensConfigurations",
"s3:ListAccessPointsForObjectLambda",
"s3:GetAccessPoint",
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:ListAccessPoints",
"s3:ListJobs",
"s3:PutStorageLensConfiguration",
"s3:CreateJob"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
我被允许访问特定的 s3 访问点。但是,当我尝试使用仅向特定访问点提供 s3:* 操作的更具体的访问时:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListStorageLensConfigurations",
"s3:ListAccessPointsForObjectLambda",
"s3:GetAccessPoint",
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:ListAccessPoints",
"s3:ListJobs",
"s3:PutStorageLensConfiguration",
"s3:CreateJob"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "arn:aws:s3:eu-west-1:598276570227:accesspoint/accesspointname"
}
]
}
这不起作用,具有此角色的 EC2 无法访问 s3 访问点(仅使用 AWS CLI 复制文件)
首先为什么会这样?根据我的估计,该角色仍然应该可以访问该接入点上的所有操作(这在某种程度上肯定是错误的!)。
其次,我试图使 s3 存储桶只能从某个 IAM 角色访问。我尝试从接入点本身的访问策略中设置它。这有一个相反的问题,它太宽松了,一切仍然可以访问它。这样做的正确方法是什么 - 将 IAM 策略放在访问点上以限制对 IAM 角色的访问或创建一个有权访问此 s3 访问点的 IAM 角色?
解决方案
我通过使用这个来完成这个工作:]
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListStorageLensConfigurations",
"s3:ListAccessPointsForObjectLambda",
"s3:GetAccessPoint",
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:ListAccessPoints",
"s3:ListJobs",
"s3:PutStorageLensConfiguration",
"s3:CreateJob"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringLike": {
"s3:DataAccessPointArn": "arn:aws:s3:eu-west-1:598276570227:accesspoint/accesspointname"
}
}
}
]
}
推荐阅读
- java - Spring通过注释为当前用户传递参数值
- javascript - 如何在传单中启用/禁用位置监视?
- angular - GET http://localhost:4200/undefined 同时显示来自 firebase 的图像
- python - 在 Python 3.6 中从嵌套字典中过滤所需的值
- c++ - 在 QuickFIX/C++ 中将 UtcTimeOnly 转换为毫秒
- c - 符号“_creat$NOCANCEL”中的“$”是什么意思?
- java - 如何显示以特定数字开头的所有值
- localization - 使用 XLIFF 本地化 TYPO3
- swift - 如何在 webview 中打开重定向页面?
- php - 如何使用 Laravel 5.8 在电子邮件中嵌入内联图像