Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda:The provided execution role does not have permissions to call DescribeNetworkInterfaces on EC2

Today I have a new AWS Lambda question, and can't find anywhere in Google.

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    };  

I bound the function with Role: lambda_excute_execution(Policy:AmazonElasticTranscoderFullAccess) And this function is not bound with any triggers now.

And then, I give the role "AdministratorAccess" Policy, I can save my source code correctly.

This role can run Functions successfully before today.

Is anyone know this error?

Thanks Very much!

like image 890
fisheep Avatar asked Dec 16 '16 05:12

fisheep


People also ask

For which of the following would a Lambda function require permissions granted by an IAM role?

A Lambda function's execution role is an AWS Identity and Access Management (IAM) role that grants the function permission to access AWS services and resources.

Can Lambda Access EC2 instance?

From AWS Lambda, SSH into your EC2 instances and run commands. AWS Lambda lets you run arbitrary code without worrying about provisioning servers. I recently worked on a project where a Lambda function SSHed into an EC2 instance and ran some commands. This is a very powerful way to control access to your EC2 instances.

Can Lambda access private subnet?

You can configure a Lambda function to connect to private subnets in a virtual private cloud (VPC) in your AWS account. Use Amazon Virtual Private Cloud (Amazon VPC) to create a private network for resources such as databases, cache instances, or internal services.

What is AWSLambdaVPCAccessExecutionRole?

AWSLambdaVPCAccessExecutionRole – Grants permissions for Amazon Elastic Compute Cloud (Amazon EC2) actions to manage elastic network interfaces (ENIs). If you are writing a Lambda function to access resources in a VPC in the Amazon Virtual Private Cloud (Amazon VPC) service, you can attach this permissions policy.


1 Answers

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).

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": "*"     }   ] } 
like image 76
Philipp Claßen Avatar answered Oct 10 '22 19:10

Philipp Claßen