Skip to content

LAB6_Set environment variables in Netlify

David Jones-Gilardi edited this page Feb 23, 2021 · 9 revisions

⚒️ Set environment variables in Netlify

Exercise time: ~5 minutes

Objectives

In this step, we will:

  • Set environment variables in Netlify for database connectivity in production deployments

We will cover:

  1. Set environment variables in Netlify
  2. Verify your environment variables
  3. Summary

1. Set environment variables in Netlify

✅ Step 1a: Go back to Netlify and navigate to Site settings in the toolbar, then choose Build & deploy from the menu on the left.

Netlify vars site settings

✅ Step 1b: Scroll down to the Environment section and choose Edit variables.

Netlify vars build edit

✅ Step 1c: Click New variable to add each key/value pair, one for each variable listed below.

Don't forget you already have all of the needed variables in your .env file.

Netlify new var

ASTRA_DB_USERNAME=battle_user
ASTRA_DB_PASSWORD=battle_password1
ASTRA_DB_KEYSPACE=battlestax
ASTRA_DB_ID=[the value you retrieved above from YOUR database]
ASTRA_DB_REGION=[the value you retrieved above from YOUR database]
GAMES_COLLECTION=games

2. Verify your environment variables

You should now have something like:

Netlify vars build edit save

✅ Step 2a: Once complete click Save and you are good to go.

Netlify save

3. Summary

At this point, you have everything hooked up and ready to go. Your code's .env file, GitHub CI/CD actions, and now your Netlify integration ALL talking to our Astra database.

Now we are ready to start editing our application code to make things happen. From here on out as you make changes to master the whole pipeline will automatically kick in, test your app, and deploy if successful.

Clone this wiki locally