Override configuration during deployment with package

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?

I see an option to use CloudFormation parameters using the plugin serverless-parameters. I can parameterize the variables that are different from dev and production environment. Here is the serverless yml file.

service: secret-project
frameworkVersion: '2'

plugins:
  - serverless-parameters
provider:
  name: aws
  runtime: nodejs12.x
  role: <role-arn>
  vpc:
    securityGroupIds:
      - Ref: securityGroupIds
    subnetIds:
      Ref: subnetId
custom:
  parameters:
    securityGroupIds:
      Type: String
      Description: Subnets in which the lambda to be deployed.
    subnetId:
      Type: List<String>
      Default: "subnet-1,subnet-2"
      Description: SubnetId to be used for lambda
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get

I have parameterized securityGroup Ids and subnet ids.

The issue I am facing is that I don’t find a way to pass parameters using sls deploy command. Alternative approach is the deploy using the Cloudformation template directly using update-stack command.

aws cloudformation update-stack --stack-name secret-project --template-body file://.serverless/cloudformation-template-update-stack.json --parameters ParameterKey=securityGroupIds,ParameterValue=sg-a123456 ParameterKey=subnetId,ParameterValue="subnet-1\,subnet-2"