Package once and deploy to multiple (AWS) environments

I am trying to improve our CI/CD process by building a single package (using sls package), then later deploying it to different AWS environments using sls deploy --package. However I use a number of SSM parameters in our serverless.yml, such as referencing KMS keys in a lambda’s execution role policy. From what I can tell, the package command actually tries to resolve these values, so the build artifacts will always be associated with a single environment.

Is there another approach to achieve this ‘build once’ → ‘deploy many’ principle with serverless in AWS? I have many target environments so doing a full build and deploy for each is not ideal.

1 Like

We’re also dealing with this issue as it particularly affects deployments which utilize plugins which perform any sort of code building such as webpack. The webpack plugin in particular performs an “npm install” in order to facilitate minimization of the functions to be deployed. We don’t want to do this in our production deploys, but because the package step builds stage specific variables into the package, we can’t easily package once while only using the serverless framework.