Zeeno
Zeeno

Reputation: 2721

AWS Codecommit Ignores environment variables

I'm attempting to deploy a practice application via AWS CodePipeline. However when I build, I notice the environment variable I added to the buildspec.yml file isn't picked up by my React application.

My buildspec file is below

version: 0.1

env:
  variables:
    REACT_APP_TEST: "If you're seeing this text, the variable worked! Yay! ^o~"

phases:
  install:
    commands:      
      - echo Installing dependencies...
      - npm i
  pre_build:
    commands:
      - echo Nothing to see in prebuld move along! :P
  build:
    commands:
      - echo Build started on `date`
      - npm run build
  post_build:
    commands:
      - echo Build completed on `date`

artifacts:
  files:
    - '**/*'

The variable above is referenced in a simple div using process.env.REACT_APP_TEST According to the docs I should be able to specify environment variables, however the text doesn't show on my application when I deploy it. Am I missing something?

Upvotes: 0

Views: 722

Answers (1)

Subin Mathew
Subin Mathew

Reputation: 2545

Please use buildspec version of 0.2. There is no reason to use 0.1 version anymore. Just change the "version: 0.1" > "version: 0.2".

The buildspec 0.1 had "environment_variables" > "plaintext" instead of "env" > "variables". However, we strongly recommend you to switch to version 0.2, which is the latest version to get the latest features.

Upvotes: 1

Related Questions