We have different AWS accounts for development and production. I would like to parameterize VPC configuration. During deployment, I would like to override VPC configuration. I tried the approach of using CLI variables in the serverless configuration. But it does not seem to be override it.
Serverless file-
service: secret-project
frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
role: ${opt:role}
vpc:
securityGroupIds:
- ${opt:securityGroup}
subnetIds:
- ${opt:subnetId1}
functions:
hello:
handler: handler.hello
events:
- http:
path: hello
method: get
Package command used -
sls package --role <role-arn> --subnetId1 <dev-subnetId> --securityGroup <dev-security-group>
Deployment command used -
sls deploy --package .serverless --role <role-arn> --subnetId1 <prod-subnetId> --securityGroup <prod-security-group>
I see that the configuration is not getting overridden. I see the the dev configuration for prod environment.
However if I don’t use --package option during deployment, the overriding works perfectly. Do we have a way to override the configuration when the package is already built?