serverless-plugin-vpc

0.0.1 • Public • Published

Serverless Plugin VPC

NPM

This plugin adds vpc support to your lambda functions.

Note: This plugin supports Serverless 0.4*

Installation

cd projectfolder
npm install serverless-plugin-vpc
  • add the plugin to your s-project.json file
"plugins": [
    "serverless-plugin-vpc"
]

Run the Plugin

  • the plugin uses a hook that is called after each deployment of a function
  • you only have to deploy your function as usual sls function deploy
  • add the following attribute to the s-function.json in your functions folder
  ...
  "vpcConfig": {
      "SubnetIds": [
          "subnet-abcda004"
      ],
      "SecurityGroupIds": [
          "sg-abcdc999"
      ]
  },
  ...

modify IAM

  • Check the role, that executes your Lambda.
  • Normally you will receive an error:
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.

  • Please add the following role policy to the functions role:
{
  "Effect": "Allow",
  "Action": [
    "ec2:CreateNetworkInterface",
    "ec2:DescribeNetworkInterfaces",
    "ec2:DeleteNetworkInterface"
  ],
  "Resource": "*"
},

Package Sidebar

Install

npm i serverless-plugin-vpc

Weekly Downloads

5

Version

0.0.1

License

MIT

Last publish

Collaborators

  • martinlindenberg