Skip to content

Lambda VPC deployment error

0

Hello, I am currently experiencing an issue deploying a lambda in a vpc. Please note that I have already done this type of deployment many times, but since yesterday I am no longer able to do it. The following error is triggered when deploying a lambda:

Lambda function <functionName> reached terminal FAILED state due to InsufficientRolePermissions(The function's execution role doesn't have permission to perform this operation.) and failed to stabilize”.

But the lambda execution role does have the following policy: arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole

Any idea ?

3 Answers
1

Hi Willysup,

Are you 100% sure of the AWS API call for which the Lambda has insufficient privileges? Maybe it's a different one than the one you believe is granted by the policy that you mention.

So, I'd suggest to go to CloudTrail to trace the type of the failing call made by this Lambda. Then, you'll be able to fix the credentials.

Best.

Didier

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago
EXPERT
reviewed 2 years ago
  • just note that the policy I mentionned is the one defined in the lambda documentation and I use it for years. I have checked cloudtrail logs and there is just one error I don't understand. the error is: errorCode = Client.DryRunOperation errorMessage = Request would have succeeded, but DryRun flag is set. eventName = CreateNetworkInterface

    I don't understand this error, as the cloudformation deploy command has no dryrun option activated (and there are several other resources in the cloudformation template without this dryrun issue). It seems that the lambda service call the CreateNetworkInterface API using a dryrun flag, but why ?

  • This is a great reminder—CloudTrail really is clutch for digging into those unexpected permission issues. Sometimes the actual failing call isn’t what you think it is. Thanks for pointing that out, Didier.

0

Hi Willysup,

Did you ever figure this out? I've previously been able to deploy Lambda functions to VPC's when only the AWSLambdaVPCAccessExecutionRole policy was assigned role to the execution role, but I'm no longer able to and I'm seeing the exact same behaviour as you describe above with the ec2:CreateNetworkInterface action.

"errorCode": "Client.DryRunOperation",
"errorMessage": "Request would have succeeded, but DryRun flag is set.",

I have tried to do this using both the console and Terraform, and it fails both times.

In addition to the permissions allowed in the AWSLambdaVPCAccessExecutionRole policy, my role is allowed to use the other actions as described in Giving Lambda functions access to resources in an Amazon VPC. However, I don't think that is the issue given the error is against the ec2:CreateNetworkInterface action and the user of that action is the Lambda function, not my/my assumed role.

answered a year ago
  • Do you have a condition on your execution role? The lambda service uses the lambda execution role to create the network interface so if you add a condition on the AssumeRolePolicyDocument it could block the use of the role by the lambda service, that's the error I had when using a condition like this one : Effect: Allow Principal: Service: - lambda.amazonaws.com Action: sts:AssumeRole Condition: ArnLike: "MyLambdaArn"

0

For those who have encountered the same issue:

The lambda service uses the lambda execution role to create the network interface so if you add a condition on the AssumeRolePolicyDocument it could block the use of the role by the lambda service, that's the error I had when using a condition like this one :

Effect: Allow
  Principal:
    Service:
      - lambda.amazonaws.com
Action: sts:AssumeRole
Condition:
  ArnLike: "MyLambdaArn"
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.