Credentials storage

In the case I have an application which is looking for an environment variable on the host machine, how to build the yml file to link the snap with this environment variable ? Furthermore, if the variable does not exist, how to create it with a pre-filled variable ?

Is it a good idea to store credentials in environment variable when deploying a soft with snap ? What is the most secure way to do it ?

The host’s environment variables are inherited to the snaps(at least, with snaps not featuring a service).

You can set the needed environment variable via a launcher.

Thanks. And is it a good idea (i.e. safe) to store credentials in a configuration with a configuration hook ?