s3存儲桶(靜態網絡託管)具有一定的策略,拒絕任何人訪問某個文件。只允許從特定的Lambda訪問文件[s3]
我該如何才能只允許特定lambda函數來訪問它? (只使用桶策略)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Authentication",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"NotResource": "arn:aws:s3:::web/auth.html"
}
]
}
UPDATE:改變與此一以前的政策,得到所需的結果
{
"Version": "2012-10-17",
"Id": "Policy1477651215159",
"Statement": [
{
"Sid": "Console administration",
"Effect": "Allow",
"NotPrincipal": {
"AWS": "arn:aws:iam::XXXX:role/role_lambda"
},
"Action": "s3:GetObject",
"NotResource": "arn:aws:s3:::web/auth.html"
}
]
}
感謝您的解決方案,但我只想使用桶策略 – dooms
您應該也可以使用桶策略來執行此操作。只需將Lambda角色的ARN:arn:aws:iam :: xxxxxxxxx:role/example_role_for_lambda發佈到您的存儲桶策略中即可。它進入'Principal'節點。 –