我正在尝试编写一个lambda,它侦听来自CloudWatch的Parameter更改事件,并通过调用boto3.client('ssm').get_parameter_history(Name=event["name"],WithDecryption=True)获取参数的历史数据。此方法在消息中失败:
botocore.exceptions.ClientError:调用GetParameterHistory操作时发生了错误(AccessDeniedException):密文引用的是不存在、在此区域不存在或不允许访问的客户主密钥。(服务: AWSKMS;状态代码: 400;错误代码: AccessDeniedException;请求ID: blah blah)
以下是lambda的执行角色:
{
"roleName": "myapp-paramstore-updates-webhook-role",
"policies": [
{
"document": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "logs:CreateLogGroup",
"Resource": "arn:aws:logs:eu-west-1:000000000000:*"
},
{
"Effect": "Allow",
"Action": [
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": [
"arn:aws:logs:eu-west-1:000000000000:log-group:/aws/lambda/ssm-paramstore-updates-webhook:*"
]
}
]
},
"name": "LambdaBasicExeRole",
"type": "inline"
},
{
"document": {
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:DescribeKey",
"ssm:GetParameter"
],
"Resource": [
"arn:aws:kms:eu-west-1:000000000000:key/*",
"arn:aws:ssm:eu-west-1:000000000000:parameter/myorg/myteam/slack/webhooks/ssm-paramstore-updates-webhook",
"arn:aws:ssm:eu-west-1:000000000000:parameter/myorg/myteam/slack/webhooks/system-eventsupdates-webhook"
]
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "ssm:GetParameterHistory",
"Resource": "arn:aws:ssm:*:*:parameter/*"
}
]
},
"name": "readonly-ssm-paramstore-updates-webhook",
"type": "inline"
}
],
"trustedEntities": [
"lambda.amazonaws.com"
]
}在我使用ssm:GetParameterHistory之前,有ssm:DescribeParameters,但是我需要获得一些版本信息,因此进行了更改。所有的东西都在同一个区域,λ和参数。
我现在需要什么额外的权限,需要什么资源来解决这个问题?
发布于 2019-02-28 11:14:40
指出需要访问键的lambda角色需要添加为KMS中的密钥用户。基本上,需要将权限授予角色(或用户),让它使用密钥对机密执行加密/解密。
这是在KMS控制台上完成的,单击客户管理键列表中的键名(假设这是您自己创建的密钥),向下滚动到关键用户,并将需要使用键的角色添加到允许用户列表中。
https://stackoverflow.com/questions/53682122
复制相似问题