Configuration
Environment variables, config files, feature flags
This page explains how to configure pycli for your environment before deploying stacks or making API calls. Configuration controls runtime behavior such as target region, deployment mode, and key-value settings that your stacks and services depend on. Getting configuration right ensures that both the CLI and the HTTP API behave predictably across environments. If you are new to pycli, read this page before running your first deploy or order request.
Before configuring pycli, make sure you have the following in place:
- Python 3.10 or later — pycli requires
python >= 3.10 - pycli installed — see the Installation section below
- Network access to your API host — required for any HTTP API interaction
- A valid API endpoint URL — for example,
https://api.example.com
Follow these steps to install pycli and its dependencies.
-
Ensure Python 3.10+ is available:
python --versionYou should see
Python 3.10.xor higher. -
Install pycli using pip:
pip install pycliThis installs pycli along with its required dependencies:
click >= 8.0,fastapi >= 0.110, andpydantic >= 2.0. -
Verify the installation:
pycli --helpYou should see the pycli help output listing available commands such as
deployandconfig.
pycli exposes configuration through the config set subcommand, which writes key-value pairs used at deploy time and by the API layer.
Setting a configuration value
Use pycli config set to define a named key with a value:
pycli config set --value=<value> <key>
| Option | Description | Required |
|---|---|---|
--value | The value to assign to the key | Yes |
<key> | The dot-notation key name (e.g., retry.count) | Yes |
Deployment flags
When running pycli deploy, two flags affect deployment behavior:
| Flag | Type | Valid values | Effect |
|---|---|---|---|
--region | String (enum) | us-east-1, us-west-2 (see note) | Selects the target deployment region |
--dry-run | Boolean | Present / absent | When present, previews the deployment without applying changes |
API base URL
All HTTP API calls are made against your configured host. In the examples throughout this documentation, https://api.example.com is used as a placeholder. Replace this with the actual URL of your deployed API server.
The following patterns represent the most common configuration tasks you will perform with pycli.
Setting a configuration key
Use dot-notation keys to organize configuration logically. For example, to set a retry count:
pycli config set --value=42 retry.count
This stores retry.count = 42 in your local pycli configuration. Your stack deployment will pick this value up at runtime.
Deploying to a specific region
Pass --region to target a particular environment. This flag is required and accepts an enum of valid region identifiers:
pycli deploy --region us-east-1 production
Substitute production with your stack name, and us-east-1 with your intended region.
Previewing a deployment before applying
Before committing a deployment, use --dry-run to validate your configuration without making any changes:
pycli deploy --region us-west-2 --dry-run staging
This is particularly useful when you have just changed a configuration value and want to confirm the deployment plan looks correct.
Configuring requests to the HTTP API
Pycli's HTTP API does not require the CLI to be installed on the client side — you can interact with it using any HTTP client such as curl. Set the Content-Type header to application/json whenever you send a request body:
curl -X POST https://api.example.com/orders \
-H 'Content-Type: application/json' \
-d '{"amount": 1500, "currency": "USD"}'
Each example below is self-contained and runnable. Replace https://api.example.com with your actual API host.
Set a configuration value before deploying
pycli config set --value=42 retry.count
Expected output:
Configuration updated: retry.count = 42
Deploy a stack to us-east-1
pycli deploy --region us-east-1 production
Expected output:
Deploying stack 'production' to region 'us-east-1'...
Done.
Preview a deployment with dry-run
pycli deploy --region us-west-2 --dry-run staging
Expected output:
[dry-run] Would deploy stack 'staging' to region 'us-west-2'. No changes applied.
Create an order via the HTTP API
curl -X POST https://api.example.com/orders \
-H 'Content-Type: application/json' \
-d '{"amount": 1500, "currency": "USD"}'
Expected response:
{
"order_id": 42,
"amount": 1500,
"currency": "USD",
"status": "pending"
}
List orders filtered by status
curl 'https://api.example.com/orders?status=paid&limit=10'
Expected response:
[
{
"order_id": 42,
"amount": 1500,
"currency": "USD",
"status": "paid"
}
]
Use the following reference to diagnose and fix common configuration and deployment problems.
Problem: pycli: command not found after installation
- Symptom: Running
pycli --helpreturns a shell error indicating the command is not found. - Likely cause: The Python
binorScriptsdirectory is not in yourPATH, or installation completed in a virtual environment that is not activated. - Fix: Activate your virtual environment (
source .venv/bin/activateon Unix,.venv\Scripts\activateon Windows) or add the relevant Python scripts directory to yourPATH.
Problem: deploy fails with an invalid region error
- Symptom: Running
pycli deploy --region <value> <stack>returns an error indicating the region value is not accepted. - Likely cause: The
--regionflag accepts a fixed enum of values. Passing an unrecognized string (e.g., a typo or unsupported region) causes validation to fail immediately. - Fix: Check the valid region values and use one of the accepted identifiers such as
us-east-1orus-west-2.
Problem: HTTP API returns 422 Unprocessable Entity on POST /orders
- Symptom: A
curlPOST to/ordersreturns a422response with a validation error body. - Likely cause: The request body is missing required fields or contains incorrectly typed values. The API uses Pydantic validation, so both field presence and type are enforced.
- Fix: Ensure your request body includes all required fields with correct types. For example:
{"amount": 1500, "currency": "USD"}. Also verify theContent-Type: application/jsonheader is present.
Problem: pycli config set does not appear to affect deployment behavior
- Symptom: You set a key with
config set, but the subsequentdeploycommand does not reflect the new value. - Likely cause: The config key name may be misspelled, or the deployment command may be reading from a different configuration source (e.g., environment variables or a separate config file) with higher precedence.
- Fix: Double-check the exact key name used with
config set. Verify that no environment variable or higher-precedence config file is overriding the value.
Problem: curl requests to the API time out or return connection errors
- Symptom: HTTP requests to
https://api.example.comhang or returnCould not resolve host/Connection refused. - Likely cause: The API server is not running, the host URL is incorrect, or network/firewall rules are blocking access.
- Fix: Confirm the API server is running and accessible from your machine. Replace the example host
https://api.example.comwith your actual deployed API URL.