How can I deploy a lambda function into multiple vpc’s region specific .
This is how my current yaml looks like
vpc:
securityGroupIds:
- {file(./config/config.{opt:stage, self:provider.stage}.{opt:region}.json):VPC_SG_ID}
- {file(./config/config.{opt:stage}.{opt:region}.json):VPC_SG_ID_US_EAST_1}
subnetIds:
- {file(./config/config.{opt:stage}.{opt:region}.json):VPC_SUBNET_1}
- {file(./config/config.{opt:stage}.{opt:region}.json):VPC_SUBNET_2}
- {file(./config/config.{opt:stage}.{opt:region}.json):VPC_SUBNET_1_US_EAST_1}
- {file(./config/config.{opt:stage}.{opt:region}.json):VPC_SUBNET_2_US_EAST_1}
I created two config files one for us-east-1 and one for us-west-2
When I run sls deploy -s dev -r us-east-1 -c serverless-aws.yml --profile qa
I get following error Error: The CloudFormation template is invalid: [/Resources/GetLocationLambdaFunction/Type/VpcConfig/SecurityGroupIds/0] ‘null’ values are not allowed in templates
I checked json template this is how it looks
“VpcConfig”: {
“SecurityGroupIds”: [
null,
“sg-xxxxxx”
],
“SubnetIds”: [
null,
null,
“subnet-xxxxx”,
“subnet-xxxxx”
]
}
Since, vpc’s are region specific how can I tell serverless yaml to use vpc-xyz when the -region is us-east-1 and vpc-abc when the -region is us-west-2?