Answers: <p>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</p>
  <pre><code>env:
    parameter-store:
      SECRET_KEY_BASE: &quot;DEV_SECRET_KEY_BASE&quot;
  </code></pre>
  <p>for &quot;release&quot; environment it was,</p>
  <pre><code>env:
    parameter-store:
      SECRET_KEY_BASE: &quot;RELEASE_SECRET_KEY_BASE&quot;
  </code></pre>
  <p>make sure you resolve merge conflicts between inter git branches before you apply.</p>
  
Answers: CC BY-SA 4.0
Answers: 2020-06-19T09:54:19.210Z
Answers: 2020-06-19T09:54:19.210Z
Answers: chaks
Body: <p>For my CodeBuild projects, I have a dev, staging and production project. Each project has an environment variable called $BUILD_ENVIRONMENT set to dev, staging and production, respectively. Each stage has its own key/value pair in Systems Manager Parameter Store. I want to use one buildspec.yml across all branches, so if I try to merge a branch or checkout a new branch, it does not copy hardcoded values in buildspec.yml. This is what I tried to do:</p>
  
  <pre><code>version: 0.2
  
  env:
    parameter-store:
      SECRET_KEY_BASE: /myproject/$BUILD_ENVIRONMENT/secret_key_base
  </code></pre>
  
  <p>But it doesn't work. There is no interpolation done and I get the following error:</p>
  
  <blockquote>
    <p>Decrypted Variables Error Message: parameter does not exist:
    /myproject/$BUILD_ENVIRONMENT/secret_base_key</p>
  </blockquote>
  
  <p>Since this is such a common use case, I am wondering if anyone found any type of solution to this?</p>
  
Comments: CC BY-SA 4.0
Comments: 2020-02-27T14:09:36.477Z
Comments: try SECRET_KEY_BASE: /myproject/${BUILD_ENVIRONMENT}/secret_key_base
Comments: malyy
Comments: CC BY-SA 4.0
Comments: 2020-03-06T02:56:41.700Z
Comments: This is now supported as explained in https://stackoverflow.com/a/60235114/8137419.
Comments: Subin Mathew
Tags: <amazon-web-services>
Title: Use dynamic values for parameter-store in aws buildspec.yml for CodeBuild
UserDisplayName: Daniel Viglione
ThreadText: # Use dynamic values for parameter-store in aws buildspec.yml for CodeBuild
  
  (Asked by: username_0 on 2019-12-23)
  
  For my CodeBuild projects, I have a dev, staging and production project. Each project has an environment variable called $BUILD\_ENVIRONMENT set to dev, staging and production, respectively. Each stage has its own key/value pair in Systems Manager Parameter Store. I want to use one buildspec.yml across all branches, so if I try to merge a branch or checkout a new branch, it does not copy hardcoded values in buildspec.yml. This is what I tried to do:
  
  ```
  version: 0.2
  
  env:
    parameter-store:
      SECRET_KEY_BASE: /myproject/$BUILD_ENVIRONMENT/secret_key_base
  
  ```
  
  But it doesn't work. There is no interpolation done and I get the following error:
  
  > Decrypted Variables Error Message: parameter does not exist:
  > /myproject/$BUILD\_ENVIRONMENT/secret\_base\_key
  
  Since this is such a common use case, I am wondering if anyone found any type of solution to this?
  
  **Tags:** amazon-web-services
  
  > **Comments:**
  > **username_1**: try SECRET_KEY_BASE: /myproject/${BUILD_ENVIRONMENT}/secret_key_base  
  > **username_2**: This is now supported as explained in https://stackoverflow.com/a/60235114/8137419.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-06-19. Score: 1
  
  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 "dev" which had following buidlspec.yml config
  
  ```
  env:
    parameter-store:
      SECRET_KEY_BASE: "DEV_SECRET_KEY_BASE"
  
  ```
  
  for "release" environment it was,
  
  ```
  env:
    parameter-store:
      SECRET_KEY_BASE: "RELEASE_SECRET_KEY_BASE"
  
  ```
  
  make sure you resolve merge conflicts between inter git branches before you apply.
  
  
  ---
  
  