The provided execution role does not have permissions to call CreateNetworkInterface on EC2

If you are trying to get an AWS Lambda added attached to a VPC, but get the error message:

The provided execution role does not have permissions to call CreateNetworkInterface on EC2

Then you can resolve this by adding a custom Inline Policy to the Lambda execution role under the Permissions tab.

How to fix this problem

Under the Lambda you want to adjust, click Permissions and select the role under Execution role.

Click the link to open the role in IAM.

Then click Add inline policy:

Then click JSON:

Now Add the JSON below into the textarea and click Review policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:DescribeNetworkInterfaces",
        "ec2:CreateNetworkInterface",
        "ec2:DeleteNetworkInterface",
        "ec2:DescribeInstances",
        "ec2:AttachNetworkInterface"
      ],
      "Resource": "*"
    }
  ]
}

Finally provide a policy name and click Create policy:

You will now be able to attach your Lambda to a VPC without the error.

Tags:

Leave a Reply

Your email address will not be published.