I'm new to this code build. I'm trying to define the environment variables in the 'environment variable tab in code build' and use those environment variables defined in buildspec.yml. The objective of doing that is to access in the react app with proces.env.REACT_APP_SOME_SPACE which should provide the value as expected, so that it can be used for API calls.
buildspec.yml
env:
variables:
// I understand this is plain text. But SOME_TOKEN provided below is defined in the aws code build as an environment variable having a value under environment tab
REACT_APP_SOME_TOKEN: ${SOME_TOKEN}
REACT_APP_SOME_SPACE: ${SOME_SPACE}
REACT_APP_BASE_URL: 'https://myurl'
REACT_APP_REQUEST_TIMEOUT: '10000'
REACT_APP_SERVICE_API_KEY: ${SERVICE_API_KEY}
...
phases:
install:
commands:
- echo "Building ${CODEBUILD_WEBHOOK_TRIGGER}"
...
What i see in process.env.REACT_APP_SOME_TOKEN for e.g., is just "${SOME_TOKEN}' or whatever that is provided as a plaintext, but not the env value defined for the variable 'REACT_APP_SOME_TOKEN' in the environment tab. I tried with the following variations, but nothing is working:
REACT_APP_SOME_SPACE: ${SOME_SPACE}
REACT_APP_SOME_SPACE: '${SOME_SPACE}'
REACT_APP_SOME_SPACE: {SOME_SPACE}
REACT_APP_SOME_SPACE: $SOME_SPACE
Questions:
- Is this correct way of doing? If not, Please advise me and provide me details
- I see that the parameter store in aws is used for storing secret keys. But want to how do I refer it in the process.env or some other env variables in react app, so I can use it my api calls to pass it over.
What I meant by environment tab mean at aws code build.
