Skip to content

An example on how to toggle the VPC configuration per stage such as disable Vpc configuration for `dev`

Notifications You must be signed in to change notification settings

hoang-innomize/serverless-toggle-vpc-example

Repository files navigation

serverless-toggle-vpc-example

An example on how to toggle the VPC configuration per stage such as disable Vpc configuration for dev.

Installation

Install node modules

npm install serverless -g
npm install

Decrypt the secrets file to get example config values

sls decrypt --stage prod --password '12345678'

NOTE: for your real project, DO NOT share the password on the source control

Configuration

You can configure Vpc per stage by using the following configuration:

custom:
  vpc:
    dev:
      # If you don't want to run Lambda under a Vpc, then just give it an empty array
      securityGroupIds: []
      subnetIds: []

    # You can add more stages here

    prod:
      securityGroupIds:
        Fn::Split:
          - ','
          - ${file(secrets.${self:provider.stage}.yml):VPC_SECURITY_GROUP_IDS}
      subnetIds:
        Fn::Split:
          - ','
          - ${file(secrets.${self:provider.stage}.yml):VPC_SUBNET_IDS}

CLI

Deploy to dev stage without Vpc

sls deploy

Deploy to prod stage will add Vpc configuration to your Lambda functions

sls deploy --stage prod

About

An example on how to toggle the VPC configuration per stage such as disable Vpc configuration for `dev`

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published