Problem exposing PostgreSQL database to external world

I’m following the guide at: External Connections · Fly Docs

I saved the PG fly.toml config and made the changes for the services as specified. When i run the deploy command i get this:

> fly deploy . --app xxx-db --image flyio/postgres:14
==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'flyio/postgres:14' remotely...
image found: img_g72wp01e5jovyxko
Error error loading appv2 config: failed loading appv2 config from /Users/void/Development/web/fly/db/dev/fly.toml: json: cannot unmarshal array into Go struct field ToplevelCheck.checks.headers of type map[string]string

any idea here? Kind of blocked and considering leaving fly.io to AWS :frowning:

You’re right, it doesn’t work. The instructions are borked. I didn’t hit that error with v0.0.462, but that doc needs to adapt to new flyctl behaviour. Thanks for the heads-up!

Can you paste your fly.toml here, minus app name?

Is this something that will take a lot of time? Is there a workaround?

# fly.toml file generated for xxx-db on 2023-02-21T09:55:47Z

app = "xxx-db"
kill_signal = "SIGTERM"
kill_timeout = 300
processes = []
services = []

[checks]
  [checks.pg]
    grace_period = "30s"
    headers = []
    interval = "15s"
    method = "get"
    path = "/flycheck/pg"
    port = 5500
    protocol = "http"
    restart_limit = 0
    timeout = "10s"
    tls_skip_verify = false
    type = "http"
  [checks.role]
    grace_period = "30s"
    headers = []
    interval = "15s"
    method = "get"
    path = "/flycheck/role"
    port = 5500
    protocol = "http"
    restart_limit = 0
    timeout = "10s"
    tls_skip_verify = false
    type = "http"
  [checks.vm]
    grace_period = "1s"
    headers = []
    interval = "1m"
    method = "get"
    path = "/flycheck/vm"
    port = 5500
    protocol = "http"
    restart_limit = 0
    timeout = "10s"
    tls_skip_verify = false
    type = "http"

[env]
  PRIMARY_REGION = "lhr"

[experimental]
  auto_rollback = false
  enable_consul = true
  private_network = true

[metrics]
  path = "/metrics"
  port = 9187

[[mounts]]
  destination = "/data"
  encrypted = false
  source = "pg_data"

Try removing the headers lines wherever you find them, then deploy again.

Just gives me a problem elsewhere, but ill post here:

> fly deploy . --app xxx-db --image flyio/postgres:14
==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'flyio/postgres:14' remotely...
image found: img_g72wp01e5jovyxko
Error error loading appv2 config: failed loading appv2 config from /Users/.../Development/web/fly/db/dev/fly.toml: json: cannot unmarshal array into Go struct field Config.mounts of type appv2.Volume

OK, so here you can change [[mounts]] to [mounts]. I think that will fix it.

These issues are happening because the new release of the Fly deployment platform has some edge cases (like Postgres cluster config) that still need to be addressed. Thanks for pointing it out.

> fly deploy . --app xxx-db --image flyio/postgres:14
==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'flyio/postgres:14' remotely...
image found: img_g72wp01e5jovyxko
Error error source setting under [mounts] is not supported for machines; remove source from fly.toml

What’s the output of flyctl version? source should be ignored in the latest versions, which we recommend for this use case. Alternatively, you could remove the source section in mounts.

flyctl v0.0.462 darwin/arm64 Commit: 2090b107 BuildDate: 2023-02-17T09:37:58Z

> fly deploy . --app xxx-db --image flyio/postgres:14
==> Verifying app config
--> Verified app config
==> Building image
Searching for image 'flyio/postgres:14' remotely...
image found: img_g72wp0xxxxxyxko
WARN Found 1 machines that are not part of the Fly Apps Platform:
xxx-db machines
ID              NAME            STATE   REGION  IMAGE                           IP ADDRESS                              VOLUME              CREATED                  LAST UPDATED
xxxxxxxxxxx  dark-water-xxxx started lhr     flyio/postgres:14.6 (v0.0.34)   fdaa:0:xxxa:a7b:xxxx:8exx:bxxx:2        vol_kexxxxxxxxxxxxxp2023-01-23T18:05:15Z     2023-01-23T18:05:22Z

? Migrate 1 existing machines into Fly Apps Platform? (y/N)

Kind of thinking i shouldn’t proceed, right? All i’m trying to do is expose the database to the outside world. Please advise.

This should be a safe, one-time action you can perform to ensure deployment changes like that can be applied.

Looking further at this, you might have a special case that would need to be dealt with individually. If you can contact your-org@support.fly.io, the issue could be picked up there with more details. Thanks for understanding.

I did send an email earlier to our support email directly, but haven’t heard from it yet.