AWS/ Serverless Fixing AccessDeniedException

Sharing is Caring

“Unhandled rejection AccessDeniedException: Your access has been denied by EC2, please make sure your function execution role have permission to CreateNetworkInterface. EC2 Error Code: UnauthorizedOperation. EC2 Error Message: You are not authorized to perform this operation.”

That’s a pretty annoying error to receive when deploying from Serverless to AWS, but the fix is really pretty simple.

Add following role policy to the functions role:

{
  "Effect": "Allow",
  "Action": [
    "ec2:CreateNetworkInterface",
    "ec2:DescribeNetworkInterfaces",
    "ec2:DeleteNetworkInterface"
  ],
  "Resource": "*"
}
Sharing is Caring

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.

1 Comments

  1. Chris G. Sellers

    This was a resolution for me with the Chalice python serverless deployment. I added

    {
    “Action”: [
    “ec2:CreateNetworkInterface”,
    “ec2:DescribeNetworkInterfaces”,
    “ec2:DeleteNetworkInterface”
    ],
    “Resource”: “*”,
    “Effect”: “Allow”
    },

    early on in my policy.json file (custom) and it got me past the EC2 permissions issue. FTW!

Comments are closed.