Use dynamic values for parameter-store in aws buildspec.yml for CodeBuild
I faced the same problem while using different SSH key pairs for different deployment environment. Usually I used to create different ssm variables per environment and then changed the name of ssm per git branch in buildspec.yml. That worked perfectly for me. For example, for deploying to stage environment i used the git branch &quot;dev&quot; which had following buidlspec.yml config
env:
  parameter-store:
    SECRET_KEY_BASE: &quot;DEV_SECRET_KEY_BASE&quot;

for &quot;release&quot; environment it was,
env:
  parameter-store:
    SECRET_KEY_BASE: &quot;RELEASE_SECRET_KEY_BASE&quot;

make sure you resolve merge conflicts between inter git branches before you apply.