quielfala
quielfala

Reputation: 599

How to fetch the ENV variables from AWS CodeBuild from a nodejs application?

I'm new to AWS and DevOps. But still experimenting here on our project, and I saw this environment variables section in CodeBuild, and I was trying to console.log the ENVIRONMENT which is sgdev1, but I'm getting undefined, when I check on CloudWatch.

I console log it like this, since I saw in our codebase it's written like that to access the environment variables. Though in this way, I'm only sure that it fetches those variables stored in my local machine, in the environment variables in Windows OS.

console.log(process.env.ENVIRONMENT)

Also I'm not that really sure where to put the environment variables, I'm quite confused since we also uses was secrets manager which holds some of our variables, then there's this codebuild env variables. I'm confused where should the variable that identify if the server is a dev site or production, but anyways the original question is how can I read these variables from codebuild environment variables? Forgive me if something stupid is going on with my question. enter image description here

Upvotes: 1

Views: 1081

Answers (1)

Majdie Gideir
Majdie Gideir

Reputation: 166

I'm going to assume you're trying to use those environment variables in your dev environment outside of CodeBuild. Those environment variables are only valid for the life of the container which your CodeBuild project is running on and are there for your build scripts to use. Where ever your code is deployed, won't have those environment variables.

Upvotes: 2

Related Questions