Configuration of the Pelion Device Management SDK can be provided in a number of ways. The list is ordered such that the methods at the top of the list have the highest order of precedence and those at the bottom the lowest.
- Parameters provided to the
mbed_cloud.sdk.sdk.SDKclass on instantiation.
- Using environment variables.
- Environment variables configured via a .env file.
The SDK can be configured with the following parameters:
||The API key created in the Pelion Device Management Portal.||Required|
||The fully qualified hostname (scheme, host, port) of the REST API.||Optional|
In a production environments, it is recommended that configuration is stored in environment variables, in a secure manner, this is the equivalent of:
For a reproducible local development environment a .env file can be used to configure the SDK without modifying the system’s environment. The file should be named .env and placed at any level of the directory tree between the project’s working directory and the root. Files closer to the working directory take priority.
Example .env file:
Take care to exclude .env files from your version control. Otherwise, you risk exposing your API keys to anyone with read access to your repository.
Create a new configuration instance.
If configuration is not supplied then the default configuration from a .env file or environment variables will be used.
- api_key (str) – (optional) API Key to use for Authentication, if provided this will override all other configuration
- host (str) – (optional) Host of the Pelion Device Management API, if provided this will override all other configuration
Instance of the logger.
The user-agent used in HTTP requests.