Building release packages for test and production environment

Hi,

In the current project, I introduced the Serverless Framework as a main infrastructure deployment tool. Our release process requires that package first must be deployed to the test environment and after successful verification deployed on the production environment.

But, those environments use a few different parameters like a domain name or API key. Those parameters are populated during package build what means that they are hardcoded by the SLS into the CloudFormation template.
e.g.
{self:custom.stages.{self:provider.stage}.apiKey, self:custom.stages.dev.apiKey}

Right now we are building two separate packages. One for test and one for prod environment, but I don’t allow to fully confirm that production package is working as expected.

Any ideas about how to resolve it and deploy the same package to both environments?