I’m developing a Lambda function that connects to an RDS database, therefore I need to associate the Lambda function to a VPC and Segurity Groups.
I’ve tried all possible config combinations, but I can’t deploy a Lambda associated to VPC and SG. I’m currently using version RC1. The error is:
An error occurred while provisioning your stack: HelloLambdaFunction
- 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…
3 - Run sls deploy
4 - Notice that your Lambdas won’t work without the VPC/SG configurations, however Serverless will create the role correctly.
5 - Edit your yml file again and add the VPC/SG configurations
6 - Run sls deploy again.
Notice that Serverless works with Cloudformation, which updates the stack everytime you deploy.