pass a list as an environment variable

Hey as the title says I’m trying to set a list as an environment variable using flyctl secrets set, e.g.

flyctl secrets set LIST_VAR='["abc", "def"]' -a app

but when I check the value of the setting that I’m using with that variable it’s that exact string rather than a list. This is on a django app. Is there anyway to pass a list with secrets set? thanks!

If encoding / decoding the var is okay, then ref: how to set secrets from JSON file? - #2 by ignoramous

1 Like

I’m not totally following, I should base64 it and put it in a file?

Environment variables are always strings, but you can do creative things to store other kind of data:

flyctl secrets set LIST_VAR='abc,def' -a app
import os
os.getenv('LIST_VAR').split(',')
# => ['abc', 'def']
2 Likes

@containerops thank you - we use django-environ so all I had to do was use env.list(‘LIST_VAR’) after passing the values in as secrets set LIST_VAR=abc,def

@ignoramous thanks for the link, ended up just being oversight on my part!

1 Like