Apps configuration as code. Easy. Centralized. Secured.
The Symeo SDK made for interacting with your Symeo secrets and configuration from python applications.
Add symeo-python
to your requirements.txt
Ex :
symeo-python==0.0.1
Run pip install -r requirements.txt
Or run directly pip install symeo-python
Add symeo-python
to your Pipfile
Ex :
[packages]
symeo-python = "0.0.1"
Run pipenv install
Create a symeo.config.yml
file in the root of your project, and define the structure and types of your application configuration:
aws:
region:
type: string
database:
host:
type: string
port:
type: integer
username:
type: string
password:
type: string
Generate the Config
class corresponding to your contract using the following command :
symeo-python build
Your configuration is then accessible with the import:
from symeo_python.config import config
For example:
from symeo_python.config import config
from psycopg2 import pool
class DatabaseClient:
def __init__(self):
self.connection_pool = pool.SimpleConnectionPool(
1,
3,
host=config.database.host,
port=config.database.port,
user=config.database.user,
password=config.database.password,
)
Create a symeo.local.yml
file in the root of your project, defining the values matching your configuration contract:
aws:
region: eu-west-3
database:
host: localhost
port: 5432
username: postgres
password: XPJc5qAbQcn77GWg
Hint : your can add your symeo.local.yml
into your .gitignore
To run locally your application using the configuration values file symeo.local.yml
, you have to wrap your command to start your application with the symeo-python
cli :
symeo-python start -- $your_command_to_start_your_application
Example 1 with uvicorn
symeo-python start -- uvicorn main:app
Example 2 with a simple python main.py
symeo-python start -- python main.py
You can specify the path and name of the local file with the -f
flag:
$ symeo-python start -f symeo.local.yml -- $your_command_to_start_your_application
After creating an environment and its api key in the Symeo platform, run
$ symeo-python start -k $YOUR_ENVIRONMENT_API_KEY -- uvicorn main:app
So the sdk fetch the values for the given environment and starts your application with those values.
Follow the Symeo platform documentation for more details.
build
command-c, --contract-file
The path to your configuration contract file. Default is symeo.config.yml
.
start
command-c, --contract-file
The path to your configuration contract file. Default is symeo.config.yml
.
-f, --values-file
The path to your local values file. Default is symeo.local.yml
.
-k, --api-key
The environment api key to use to fetch values from Symeo platform. If empty, values will be fetched from local value file (symeo.local.yml
by default). If specified, parameter -f, --values-file
is ignored.
-a, --api-url
The api endpoint used to fetch your configuration with the api key. Default is https://api.symeo.io/api/v1/values
.
To get some help with the CLI, please use the following commands :
symeo-python build --help
or
symeo-python start --help