# Move from Render, Railway or Heroku

You run a web service, a worker, Postgres, Redis and a cron job on a platform, and you want them in your own AWS, Google Cloud or Azure account without writing infrastructure code. This page is the whole move: the spec that matches your app, the data, the cut-over. Pilot builds what the spec declares, then keeps it running and scaled.

Plan for an afternoon, most of it waiting for a database copy. Nothing on your current platform changes until the last step, and every step before it can be repeated.

## What you need

- A cloud account you own, with nothing in it you care about yet. An empty account or project is ideal.
- Your app as a container image in a registry your cloud can pull from. Render and Railway build images for you; on Heroku, build one with the same Dockerfile or with `pack build` and push it to your cloud's registry (ECR, Artifact Registry, ACR) or to GitHub's.
- The app's environment variables, sorted into two piles: configuration (log level, feature flags, URLs) and secrets (API keys, signing keys).
- A way to run `pg_dump` against the current database, and the size of that database.

## 1. Connect the account

Follow `https://infrapilot.fly/docs/onboard.md` with mode `new`. For a build, Pilot's access must include creating resources: the `build` policy on AWS, the build roles on Google Cloud, Contributor on a resource group on Azure. The provider guide shows exactly what that allows.

## 2. Put the secrets in your cloud's secret store

Pilot never handles a secret's value. Create each secret yourself, once, and give the spec its reference:

```bash
# AWS
aws secretsmanager create-secret --name stripe-key --secret-string "$STRIPE_KEY" --query ARN --output text
# Google Cloud
printf %s "$STRIPE_KEY" | gcloud secrets create stripe-key --data-file=- && echo projects/$PROJECT/secrets/stripe-key
# Azure
az keyvault secret set --vault-name $VAULT --name stripe-key --value "$STRIPE_KEY" --query id -o tsv
```

Leave `DATABASE_URL` and `REDIS_URL` for step 4: the new database and cache do not exist yet.

## 3. Write the spec

One file replaces the platform's dashboard. This is a typical app; change the names, the image and the sizes:

```yaml
version: 1
fleet: acme
workloads:
  - name: web
    kind: http-service
    description: the web app and API, about 20 requests a second at peak
    spec:
      image: ghcr.io/acme/app:1.4.2
      port: 8080
      health_path: /healthz
      domains: [app.acme.dev]
      env: {LOG_LEVEL: info, RAILS_ENV: production}
      secrets: {STRIPE_KEY: "<the reference from step 2>"}
  - name: worker
    kind: worker
    description: background jobs from the queue, a few a second
    spec:
      image: ghcr.io/acme/app:1.4.2
      command: ["bundle", "exec", "sidekiq"]
  - name: db
    kind: database
    description: the app's Postgres, about 8 GB
    spec: {engine: postgres, version: "16", size: small, storage_gb: 20}
  - name: cache
    kind: cache
    spec: {engine: redis, memory_gb: 1}
  - name: nightly
    kind: schedule
    spec: {cron: "0 3 * * *", target: web, command: ["bin/rails", "reports:nightly"]}

intents:
  - name: the app stays fast
    objectives:
      - {resource: web, metric: latency_p99_ms, below: 500}
    max_monthly_cost_usd: 300
```

Match what you have now. Platform sizes map roughly like this: one "standard" web dyno or a 512 MB to 1 GB instance is the default `cpu: 0.5`, `memory_mb: 1024`; a "basic" or "starter" Postgres is `size: small`. The objective's metric name depends on the cloud: `GET /api/types/<provider>` lists them, and your coding agent picks the right one during setup. The cost ceiling is a limit, not a target: Pilot starts small.

A queue the worker reads from, or a bucket for uploads, is one more workload (`kind: queue`, `kind: bucket`).

## 4. Let Pilot build it

Submit the spec and start Pilot (the last steps of `https://infrapilot.fly/docs/onboard.md`). It builds in dependency order: the database and cache first, then the services, then the schedule. A database takes several minutes. Each resource is checked after it is created, and the ledger shows every step.

When it is done, the review lists each workload, what it costs and where its logs are. The web service has an address of the cloud's own (`*.run.app`, `*.azurecontainerapps.io`, a load balancer name).

A large app is built over several passes: Pilot's changes are rate-limited, so after about ten resources it pauses for a minute or two and carries on. The review names anything still missing or unfinished.

### Point the app at its database and cache

Pilot does not put a database's address or password into your services: a password is a secret, and Pilot never handles one. Under the database and the cache, the review shows a **Connect** block: the host and port, and where the password is kept.

| Cloud | The database's password | What you do |
| --- | --- | --- |
| AWS | made by AWS, kept in a Secrets Manager secret (the review gives its ARN) | Tag that secret `infrapilot:fleet=<fleet>` and reference it as `<ARN>:password::`, or write a full `DATABASE_URL` into a secret of your own. |
| Google Cloud | none yet | Create a database user (`gcloud sql users create`, or an IAM database user for the service's account), then write `DATABASE_URL` into Secret Manager. |
| Azure | none: the server takes Microsoft Entra sign-in only, and each service's own identity is allowed in | Have the app sign in with its managed identity (a token as the password; the review says how). If the app needs a password string, create a database role yourself and write `DATABASE_URL` into Key Vault. |

Then add the references to the spec and submit it again; Pilot updates the services:

```yaml
      secrets:
        STRIPE_KEY: "<the reference from step 2>"
        DATABASE_URL: "<the reference to the secret you just wrote>"
      env: {LOG_LEVEL: info, RAILS_ENV: production, REDIS_URL: "rediss://<the cache's host>:6379"}
```

The cache has no password on AWS and Google Cloud (it is reachable from the fleet's services only), so its address can go in `env`. Use `rediss://` where the review says TLS is required and `redis://` where it says there is none. On Azure the cache has no access keys either: the service's identity is given access, and the app signs in with it.

Open the web service's address: the app runs against an empty database.

## 5. Move the data

The new database is private: only the fleet's services reach it. Run the copy from somewhere inside, which for most teams means a one-off job in the fleet:

```yaml
  - name: restore
    kind: schedule
    spec:
      cron: "0 0 1 1 *"          # never mind the schedule: run it once by hand, then remove it
      image: postgres:16
      command: ["sh", "-c", "pg_dump --no-owner --no-acl \"$SOURCE_URL\" | psql \"$DATABASE_URL\""]
      secrets:
        SOURCE_URL: "<a secret holding your current platform's database URL>"
        DATABASE_URL: "<the same reference the web service uses>"
```

Do a practice run now, while the old app is still serving, to learn how long it takes. For a database of a few gigabytes it is minutes.

For the real move you need a moment when nothing writes to the old database:

1. Put the old app in maintenance mode (Heroku: `heroku maintenance:on`; Render and Railway: suspend the service or scale it to zero).
2. Run the copy job again against the emptied new database.
3. Check a few row counts on both sides.

A database too large or too busy for a maintenance window needs logical replication instead (`pg_dump --schema-only`, then a publication on the old side and a subscription on the new one); set that up with your cloud's migration service and cut over when the lag is zero.

Redis usually holds only a cache and job queues: let the queues drain before step 1 and start the new cache empty.

## 6. Cut over DNS

The review shows two kinds of DNS record for `app.acme.dev`: one that proves you own the name, so the certificate can be issued, and one that points the name at the new service. Add the first one early (it changes nothing for visitors) and wait for the certificate.

A day before the move, lower the TTL on the existing record to 60 seconds. At the move, after the data is across, point the name at the new service. Keep the old app in maintenance mode, not deleted, for a day: going back is one DNS change.

## 7. After the move

- Deploy with `infrapilot deploy web <image>` from CI (`https://infrapilot.fly/docs/deploy.md`). A deploy that fails its health check is rolled back.
- Remove the `restore` workload from the spec.
- Watch the first real traffic with Pilot at whatever level you chose. It resizes the services and the database's capacity as load arrives, inside the cost ceiling, and asks when it reaches a limit.
- When you are sure, delete the app on the old platform.

## What differs by cloud

- **A worker on Google Cloud must answer on `$PORT`.** Cloud Run runs services that listen; a process that only polls a queue (Sidekiq, Celery) needs a small health endpoint, or runs as a `schedule`. On AWS and Azure a worker needs no port.
- **Sizes round up.** On Google Cloud a service gets at least 1 vCPU; on AWS `cpu` and `memory_mb` become the next Fargate size.
- **HTTPS on AWS needs a domain.** A load balancer has no certificate for its own name, so without `domains` the service answers over HTTP. Cloud Run and Container Apps give an HTTPS address of their own.
- **A schedule on Azure runs in UTC.** Container Apps jobs have no time zone: write the cron in UTC. AWS and Google Cloud honour `timezone`.
- **A custom domain on Azure must be a subdomain** (`app.acme.dev`, not `acme.dev`). `engine: valkey` for a cache is built on AWS only; elsewhere the cache is Redis.
- **Azure has no default network**, so Pilot creates one small virtual network for the fleet. AWS uses the account's default VPC and Google Cloud the project's `default` network; where one is missing, Pilot asks.
- **Before the build, each cloud asks for a few things once** that Pilot may not do itself (service-linked roles and three policies on AWS; service accounts and private services access on Google Cloud; on Azure, whether Pilot may assign two narrow roles to the identities it creates). The provider guide lists them with the commands, and Pilot asks for whatever is missing.

## What does not carry over

- **Build from source.** Pilot runs images; it does not build them. Keep the build in CI.
- **Preview environments per pull request.** Not in the alpha.
- **Add-ons** beyond Postgres and Redis (search, mail, logging services) stay where they are, or become ordinary resources in your account that Pilot observes.
- **The platform's router features**: request timeouts, sticky sessions and the like are your cloud's load balancer settings now, and the defaults differ. Check any your app depends on.
