Synopsis
kosli list environments [flags]
Flags
| Flag | Type | Description |
|---|---|---|
-h, --help | bool | help for environments |
--name | string | [optional] Only list environments whose name contains this substring (case-insensitive). |
-o, --output | string | [defaulted] The format of the output. Valid formats are: [table, json]. (default “table”) |
--page | int | [defaulted] The page number of a response. (default 1) |
-n, --page-limit | int | [defaulted] The number of elements per page. (default 15) |
--sort | string | [optional] The field to sort environments by. Valid values are: [name, last_modified_at, last_changed_at]. (defaults to name) |
--sort-direction | string | [optional] The direction to sort environments in. Valid values are: [asc, desc]. (defaults to asc) |
--space-id | strings | [optional] Only list environments in the space with this ID. Can be repeated to match more than one space. |
--tag | stringArray | [optional] Only list environments that have this tag, given as ‘key’ or ‘key:value’. Can be repeated to match more than one tag. |
--type | strings | [optional] Only list environments of this type. Valid types are: [K8S, ECS, S3, lambda, server, docker, azure-apps, cloud-run, logical]. Can be repeated to match more than one type. |
Flags inherited from parent commands
| Flag | Type | Description |
|---|---|---|
-a, --api-token | string | The Kosli API token. |
-c, --config-file | string | [optional] The Kosli config file path. Config is read from this path or the default only, never implicitly from the current directory. (default “$HOME/.kosli.yml”) |
--debug | bool | [optional] Print debug logs to stdout. |
-H, --host | string | [defaulted] The Kosli endpoint. (default “https://app.kosli.com”) |
--http-proxy | string | [optional] The HTTP proxy URL including protocol and port number. e.g. http://proxy-server-ip:proxy-port |
-r, --max-api-retries | int | [defaulted] How many times should API calls be retried when the API host is not reachable. (default 3) |
--org | string | The Kosli organization. |
-q, --quiet | bool | [optional] Suppress non-critical warning messages. Errors and normal output are not affected. If both --quiet and --debug are set, --debug wins. |
Live Example
To view a live example of ‘kosli list environments’ you can run the command below (for the cyber-dojo demo organization).export KOSLI_ORG=cyber-dojo
# The API token below is read-only
export KOSLI_API_TOKEN=Pj_XT2deaVA6V1qrTlthuaWsmjVt4eaHQwqnwqjRO3A
kosli list environments --output=json
View example output
View example output
[
{
"org": "cyber-dojo",
"name": "aws-beta",
"type": "ECS",
"description": "The ECS cluster for staging cyber-dojo",
"last_modified_at": 1790775383.9179575,
"last_reported_at": 1790775383.9179575,
"last_changed_at": 1790774544.0207713,
"state": true,
"include_scaling": false,
"tags": {
"url": "https://beta.cyber-dojo.org/"
},
"policies": [
"provenance",
"pull-request",
"snyk-scan-aws-beta",
"trail-compliance-aws-beta"
],
"included_environments": null,
"archived_at": null,
"archived_by": null
},
{
"org": "cyber-dojo",
"name": "aws-beta-terraform-drift-detection",
"type": "server",
"description": "Detection of drift of the Infrastructure-as-code components of aws-beta",
"last_modified_at": 1790775308.9382122,
"last_reported_at": 1790775308.9382122,
"last_changed_at": 1790775009.1899378,
"state": true,
"include_scaling": false,
"tags": {},
"policies": [
"provenance"
],
"included_environments": null,
"archived_at": null,
"archived_by": null
},
{
"org": "cyber-dojo",
"name": "aws-prod",
"type": "ECS",
"description": "The ECS cluster for production cyber-dojo",
"last_modified_at": 1790775358.377852,
"last_reported_at": 1790775358.377852,
"last_changed_at": 1790759338.4899325,
"state": true,
"include_scaling": false,
"tags": {
"url": "https://cyber-dojo.org/"
},
"policies": [
"production-promotion",
"provenance",
"pull-request",
"snyk-scan-aws-prod",
"trail-compliance-aws-prod"
],
"included_environments": null,
"archived_at": null,
"archived_by": null
},
{
"org": "cyber-dojo",
"name": "aws-prod-terraform-drift-detection",
"type": "server",
"description": "Detection of drift of the Infrastructure-as-code components of aws-prod",
"last_modified_at": 1790775212.2658806,
"last_reported_at": 1790775212.2658806,
"last_changed_at": 1790420323.0627275,
"state": true,
"include_scaling": false,
"tags": {},
"policies": [
"provenance"
],
"included_environments": null,
"archived_at": null,
"archived_by": null
},
{
"org": "cyber-dojo",
"name": "production",
"type": "logical",
"description": "Production environments for cyber-dojo",
"last_modified_at": 1790759338.4899325,
"last_reported_at": null,
"last_changed_at": 1790759338.4899325,
"state": true,
"include_scaling": false,
"tags": {},
"policies": null,
"included_environments": [
"aws-prod",
"aws-prod-terraform-drift-detection"
],
"archived_at": null,
"archived_by": null
},
{
"org": "cyber-dojo",
"name": "staging",
"type": "logical",
"description": "Staging environments for cyber-dojo",
"last_modified_at": 1790775009.1899378,
"last_reported_at": null,
"last_changed_at": 1790775009.1899378,
"state": true,
"include_scaling": false,
"tags": {},
"policies": [],
"included_environments": [
"aws-beta",
"aws-beta-terraform-drift-detection"
],
"archived_at": null,
"archived_by": null
}
]
Examples Use Cases
These examples all assume that the flags--api-token, --org, --host, (and --flow, --trail when required), are set/provided.
list all environments for an org
list all environments for an org
kosli list environments
show the second page of environments, 25 per page
show the second page of environments, 25 per page
kosli list environments
--page 2
--page-limit 25
list environments whose name contains a substring (in JSON)
list environments whose name contains a substring (in JSON)
kosli list environments
--name prod
--output json
list K8S and ECS environments tagged with team=platform
list K8S and ECS environments tagged with team=platform
kosli list environments
--type K8S
--type ECS
--tag team:platform
list environments sorted by when they last changed, newest first
list environments sorted by when they last changed, newest first
kosli list environments
--sort last_changed_at
--sort-direction desc