gpt4 book ai didi

amazon-web-services - 在 AWS Lambda 中担任角色,在 SSM 调用时拒绝访问

转载 作者:行者123 更新时间:2023-12-03 23:16:53 24 4
gpt4 key购买 nike

我在调用 SSM 的 Lambda 函数中遇到错误:

AccessDeniedException: User: arn:aws:sts::redacted:assumed-role/LambdaBackend_master_lambda/SpikeLambda is not authorized to perform: ssm:GetParameter on resource: arn:aws:ssm:eu-west-1:redacted:parameter/default/key/api



但是,我很确定我正确配置了这个:

角色,使用 Lambda 的 AssumeRole(尽管我们知道从错误消息中可以工作)。
λ aws iam get-role --role-name LambdaBackend_master_lambda
{
"Role": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
}
}
]
},
"RoleId": "redacted",
"CreateDate": "2017-06-23T20:49:37Z",
"RoleName": "LambdaBackend_master_lambda",
"Path": "/",
"Arn": "arn:aws:iam::redacted:role/LambdaBackend_master_lambda"
}
}

我的政策:
λ aws iam list-role-policies --role-name LambdaBackend_master_lambda
{
"PolicyNames": [
"ssm_read"
]
}
λ aws iam get-role-policy --role-name LambdaBackend_master_lambda --policy-name ssm_read
{
"RoleName": "LambdaBackend_master_lambda",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:DescribeParameters"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ssm:GetParameters"
],
"Resource": "arn:aws:ssm:eu-west-1:redacted:parameter/*",
"Effect": "Allow"
}
]
},
"PolicyName": "ssm_read"
}

我已经通过策略模拟器运行它,它似乎很好!

AWS IAM policy sim

最佳答案

今天玩了这个,得到了以下结果,从 ssm:GetParameters 中删除了 s并使用 ssm:GetParameter使用 GetParameter 操作时似乎有效。即AWS_PROFILE=pstore aws ssm get-parameter --name param_name .这让我有点奇怪,因为我在 iam 操作文档 here 中根本找不到这个。 .然而,它似乎确实有效,并且 ssm 仍然有点缺乏记录。
亚马逊已经更新并移动了它的文档。新docs包括ssm:GetParametersssm:GetParameter .

{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ssm:DescribeParameters"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ssm:GetParameter"
],
"Resource": "arn:aws:ssm:eu-west-1:redacted:parameter/*",
"Effect": "Allow"
}
]
}

关于amazon-web-services - 在 AWS Lambda 中担任角色,在 SSM 调用时拒绝访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44734572/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com