1

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Okay, so I won't be able to access those variables in my screenshot. But I'm confused how would my app detects if it's in a development environment or production? Where would it read the information once it's deployed in AWS?
Whoever set up your dev and prod environment would've probably set up the envs. How is your environmment set up? Is it elasticbeanstalk or just an EC2? Windows or linux server?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.