title: How to pass environment variable to the buildspec.yml for AWS codebuild
body: <p>I have the following command in my buildspec.yml file in my gatsby site root directory.</p>
  
  <pre><code>version: 0.2
  
  phases:
    install:
      commands:
        - npm i npm@latest -g
        - npm install --global gatsby-cli
        - npm install
        - pip install --upgrade pip
        - pip install --upgrade awscli
    build:
      commands:
        - gatsby build
    post_build:
      commands:
        - aws s3 sync public/ s3://stagging
  </code></pre>
  
  <p>I have 2 environments, staggin and production. Is there a way that i can maybe automate the sync command here to use some kind of variable to change the environment when i do codebuild. Maybe i can pass the environment name via command line.</p>