Skip to content

Instantly share code, notes, and snippets.

@hoang-innomize
Last active November 12, 2019 03:22
Show Gist options
  • Save hoang-innomize/192192145f02c408cdb56f58e98bd4c6 to your computer and use it in GitHub Desktop.
Save hoang-innomize/192192145f02c408cdb56f58e98bd4c6 to your computer and use it in GitHub Desktop.
A serverless example for configuring different vpc per stage
service: serverless-toggle-vpc-example
provider:
runtime: nodejs10.x
name: aws
vpc: ${self:custom.vpc.${self:provider.stage}}
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}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment