New Feature: Env Variables in fly.toml

Howdy folks. Starting today you can add environment variables to your fly.toml file:

[env]
  LOG_LEVEL = "debug"
  RAILS_ENV = "production"
  S3_BUCKET = "my-app-production"

Notes:

  • Variable names are passed to your app as-is, so make sure you get your casing right.
  • Variable names cannot begin with FLY_
  • Values must be strings
  • Secrets take priority if both a secret and env variable have the same name
  • Env variables are NOT encrypted… please use secrets for sensitive data :wink:
3 Likes

This is awesome, so many times we continued to set our secrets because we were u sure of their values :joy:.

2 Likes

@michael this is great but unfortunately it’s limited if you want to use the same fly.toml file for multiple environments.

It would be great if we could have multiple environments in the same file.

We’re working through how best to support multiple environments. Do you like to have environment variables in your config file generally? Or would you rather set them with our CLI (like flyctl secrets but less secret)?

For basic flags and configs, we like to have the environment variables in the config file, and for api keys / key pairs / secrets we would set them using the CLI.