我想使用 Amazon 教程在 python 中创建一个amba部署包(带有依赖项)。
当我用
推送 .zip 包时aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip
我收到以下错误
An error occurred (AccessDeniedException) when calling the UpdateFunctionCode operation:
User: arn:aws:iam::<ACCOUNT-ID>:user/jeanclaude is not authorized to perform: lambda:UpdateFunctionCode
on resource: arn:aws:lambda:eu-west-3:<ACCOUNT-ID>:function:my-function
我应该向 jeanclaude 授予哪种策略才能让他获得正确的访问权限?
AWSLambdaFullAccess
政策附加到您的用户/角色。这仅用于测试目的,稍后您可以根据需要减少权限。aws lambda update-function-code --function-name "helloworld" --zip-file "fileb://./helloworld.zip" --region "eu-west-2"
它应该可以工作,请注意,对于
update-function-code
强制字段只是 --function-name
其他字段是可选的。aws cli update-fuction-code
create-function
命令,它只有以下字段为必填字段,所有其他字段都是可选的 aws cli 文档 create-function
--function-name <value>
--runtime <value>
--role <value>
--handler <value>
这里的
--role
是 lambda 在执行时与其他服务交互所需的角色(不要被上面的用户混淆)
您可以创建授予
UpdateFunctionCode
的策略,将该策略分配给组,然后将该组分配给用户。
您的政策应如下所示:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Allow UpdateFunctionCode",
"Effect": "Allow",
"Action": "lambda:UpdateFunctionCode",
"Resource": [
"arn:aws:lambda:us-east-1:<account_id>:function:your_function"
]
}
]
}