Best way to list app instances at runtime

As the title says: what would be the recommended way to list all instances (including stopped ones) in a running application. Unfortunately, the DNS technique only lists started instances.

Currently, I can only think of the fly CLI or probably using the management API directly. If so, I’d be thankful for an example snippet.

Our CLI just uses our Machines API:

I’d recommend using the List Machines endpoint. Does that help?

Probably, I need to test. I just wanted to explore the possibilities before implementing it. The only disadvantage I see is that I need to provide an API access token to the running application,right?

That’s true. You can issue a readonly token though:

$ fly tokens create --help
Create API tokens

  fly tokens create [command]

Available Commands:
  deploy       Create deploy tokens
  litefs-cloud Create LiteFS Cloud tokens
  machine-exec Create a machine exec token
  org          Create org deploy tokens
  readonly     Create read-only org tokens
  ssh          Create token for SSH'ing to a single app

  -h, --help   help for create

Global Flags:
  -t, --access-token string   Fly API Access Token
      --debug                 Print additional logs and traces
      --verbose               Verbose output

Use "fly tokens create [command] --help" for more information about a command.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.