udacity / cdond-c3-projectstarter

Cloud DevOps C3 Refresh Project Starter - Build CI/CD Pipelines, Monitoring & Logging - Spring 2020
Other
61 stars 2.33k forks source link

Update the frontend folder with .env file #98

Closed Los-merengue closed 2 years ago

Los-merengue commented 2 years ago

I observe the frontend folder needed a .env file to enable the IP address to be picked from that file during frontend/backend testing. I would also appreciate it if the changes I have made can be merged with my parent repository so it would be part of my commit contribution

SudKul commented 2 years ago

Hey @Los-merengue You are right that the frontend needs to know the backend API_URL. In production environments, we do not encourage using .env files pushed to the Github repo. So, you have to come up with a way to fetch the API_URL using commands so that the CircelCI containers can fetch and supply it to the next job. Here's how it would look like in your CircleCI config:

export BACKEND_IP=$(aws ec2 describe-instances...............)
export API_URL="http://${BACKEND_IP}:3030"
echo "API_URL = ${API_URL}"
echo API_URL="http://${BACKEND_IP}:3030" >> frontend/.env
cat frontend/.env