AWS Lambda:提供的执行角色无权调用 EC2 上的 DescribeNetworkInterfaces [英] AWS Lambda:The provided execution role does not have permissions to call DescribeNetworkInterfaces on EC2
问题描述
今天我有一个新的 AWS Lambda 问题,在 Google 中找不到任何地方.
Today I have a new AWS Lambda question, and can't find anywhere in Google.
我新建了一个 Lambda 函数,毫无疑问.但是当我在这个函数中输入任何代码时[例如.console.log();] 并点击保存",出现错误:提供的执行角色无权在 EC2 上调用 DescribeNetworkInterfaces"
I new a Lambda function, there is no question. But when I input any code in this function[eg. console.log();] and click "Save", error is occured: "The provided execution role does not have permissions to call DescribeNetworkInterfaces on EC2"
exports.handler = (event, context, callback) => {
callback(null, 'Hello from Lambda');
console.log(); // here is my code
};
我将函数与角色绑定:lambda_excute_execution(Policy:AmazonElasticTranscoderFullAccess)而且这个函数现在没有绑定任何触发器.
I bound the function with Role: lambda_excute_execution(Policy:AmazonElasticTranscoderFullAccess) And this function is not bound with any triggers now.
然后,我给角色AdministratorAccess"策略,我可以正确保存我的源代码.
And then, I give the role "AdministratorAccess" Policy, I can save my source code correctly.
此角色可以在今天之前成功运行 Functions.
This role can run Functions successfully before today.
有人知道这个错误吗?
非常感谢!
推荐答案
如果您尝试在 VPC 中部署 Lambda 而没有为其提供所需的网络接口相关权限,则此错误很常见ec2:DescribeNetworkInterfaces
、ec2:CreateNetworkInterface
和 ec2:DeleteNetworkInterface
(参见 AWS 论坛).
This error is common if you try to deploy a Lambda in a VPC without giving it the required network interface related permissions ec2:DescribeNetworkInterfaces
, ec2:CreateNetworkInterface
, and ec2:DeleteNetworkInterface
(see AWS Forum).
例如,这是一个允许将 Lambda 部署到 VPC 的策略:
For example, this a policy that allows to deploy a Lambda into a VPC:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:DescribeNetworkInterfaces",
"ec2:CreateNetworkInterface",
"ec2:DeleteNetworkInterface",
"ec2:DescribeInstances",
"ec2:AttachNetworkInterface"
],
"Resource": "*"
}
]
}
这篇关于AWS Lambda:提供的执行角色无权调用 EC2 上的 DescribeNetworkInterfaces的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!