Feedback: Infrastructure as Code

Hey folks! We’ve released an experimental first version of Railway Infrastructure as Code.

You can now define, import, preview, and apply project configuration from a single .railway/railway.ts file.

This is meant to manage project-level configuration like services, databases, buckets, domains, variables, replicas, and groups from code.

Docs are here: https://docs.railway.com/infrastructure-as-code. Only TypeScript is supported for now, which requires the Railway TypeScript SDK to be installed as a dependency, but we plan to add support to other languages as well.

This is intentionally experimental, so please expect rough edges. We’re especially interested in feedback on the authoring experience, imported config quality, plan/apply output, and anything that feels confusing or unsafe.

You'll need to upgrade to the latest version of the CLI (5.2.0). If you try it, please share what worked, what didn’t, and what would make it easier to trust in real projects.

Under Review

0 Threads mention this feature

14 Replies

2 months ago

I am finding the errors output by "railway config apply" to be a bit mysterious, for example, I had the wrong region setup for a bucket being created which causes the tool to error but the message is just "Invalid RailwayChangeSet patch" with no further information, it would be good to have some --debug option to see whats actually gone wrong


xeofd

I am finding the errors output by "railway config apply" to be a bit mysterious, for example, I had the wrong region setup for a bucket being created which causes the tool to error but the message is just "Invalid RailwayChangeSet patch" with no further information, it would be good to have some --debug option to see whats actually gone wrong

2 months ago

It would also be good to be able to track/set the region on databases through IaC, for example, if I setup a new db through IaC it automatically provisions in one of the us regions, when I would prefer it to be provisioned within the EU


2 months ago

It also seems that when you run a "railway config pull" it doesn't pull in any of the environment variables that were set manually in railway UI. I would expect when you run a pull it should pull in the variable names and at least set them to "preserve()" as the docs suggest you do when writing it yourself.


xeofd

It would also be good to be able to track/set the region on databases through IaC, for example, if I setup a new db through IaC it automatically provisions in one of the us regions, when I would prefer it to be provisioned within the EU

2 months ago

another note on regions, having setup a bucket manually through the UI and setting it to EU, when I then pull that config down, the region its is set to is "ams", I cant find that in the documentation as a region reference, so im not sure if the documentation is out of date? (https://docs.railway.com/deployments/regions). It would be good if the options for regions could be typed, i.e {region: "ams", "us-east1", "asia-southeast1", ...etc} to remove any confusion


Anonymous
PRO

2 months ago

This is not IaC, its Railway-as-Code. Please adopt terraform provider properly.


2 months ago

There seems to be a bug with adding buckets to groups, if you create a new bucket and add it to a group the apply command will fail with another obscure message, I see the same behavior for existing buckets being added to groups, or if I add a bucket to a group in the UI, pull the config and then run an apply, it seems to want to remove it from the group according to the plan step and then during apply it fails


tko
PRO

2 months ago

How to attach a volume to a database service? Let's say I will need 500 GB of disk space available.

Also, how to attach a volume to a regular service? Couldn't find the right examples so far.


tko
PRO

2 months ago

I couldn't apply the config changes due to the error below:


 railway config plan

 Could not read Railway configuration

Railway configuration

Using .railway/railway.ts

Error error: Cannot find module '/Users/tko/dev/github/namehash/ensnode/node_modules/.pnpm/railway@3.1.2/node_modules/railway/dist/iac/index.cjs?namespace=1781194186859' imported from /Users/tko/dev/github/namehash/ensnode/.railway/railway.ts?t=1781194186843&namespace=1781194186859

IaC runner returned diagnostics

I've checked the /Users/tko/dev/github/namehash/ensnode/node_modules/.pnpm/railway@3.1.2/node_modules/railway/dist/iac/index.cjs path and I can see the file exists.

The .railway/railway.ts file defines a simple auto-generated setup:


import { defineRailway, project, service } from "railway/iac";

export default defineRailway(() => {

  const web = service("web", {

    // Add build/start commands when Railway cannot infer them.

    // build: "pnpm install --frozen-lockfile && pnpm build",

    // start: "pnpm start",

    env: {

      NODE_ENV: "production",

    },

  });

  return project("ensnode", {

    resources: [web],

  });

});

xeofd

There seems to be a bug with adding buckets to groups, if you create a new bucket and add it to a group the apply command will fail with another obscure message, I see the same behavior for existing buckets being added to groups, or if I add a bucket to a group in the UI, pull the config and then run an apply, it seems to want to remove it from the group according to the plan step and then during apply it fails

Hey @xeofd! We released updates addressing some of your concerns, including verbose validation output by default on invalid config patches and better support for groups in buckets. Please ensure you've updated the CLI and the TypeScript SDK to the latest available versions.


tko

How to attach a volume to a database service? Let's say I will need `500 GB` of disk space available. Also, how to attach a volume to a regular service? Couldn't find the right examples so far.

When deploying a database, a volume will be automatically provisioned and mounted. For now we run with the same defaults as you'd find when deploying a database via the UI. The only customizable parameter via IaC as of now is the region, the rest must be managed via the dashboard. We plan on gradually adding more parameters to ensure parity with the dashboard so you don't leave the editor.


tko

I couldn't apply the config changes due to the error below: ``` ❯ railway config plan ✗ Could not read Railway configuration Railway configuration Using .railway/railway.ts Error error: Cannot find module '/Users/tko/dev/github/namehash/ensnode/node_modules/.pnpm/railway@3.1.2/node_modules/railway/dist/iac/index.cjs?namespace=1781194186859' imported from /Users/tko/dev/github/namehash/ensnode/.railway/railway.ts?t=1781194186843&namespace=1781194186859 IaC runner returned diagnostics ``` I've checked the `/Users/tko/dev/github/namehash/ensnode/node_modules/.pnpm/railway@3.1.2/node_modules/railway/dist/iac/index.cjs` path and I can see the file exists. The `.railway/railway.ts` file defines a simple auto-generated setup: ```ts import { defineRailway, project, service } from "railway/iac"; export default defineRailway(() => { const web = service("web", { // Add build/start commands when Railway cannot infer them. // build: "pnpm install --frozen-lockfile && pnpm build", // start: "pnpm start", env: { NODE_ENV: "production", }, }); return project("ensnode", { resources: [web], }); }); ```

Could you please try upgrading to the latest version of the TypeScript SDK? You're currently using railway@3.1.2, and we released some fixes about imports that could help your case.


futurepastori

Hey @xeofd! We released updates addressing some of your concerns, including verbose validation output by default on invalid config patches and better support for groups in buckets. Please ensure you've updated the CLI and the TypeScript SDK to the latest available versions.

2 months ago

Have updated to try out the changes, when I now run railway config plan it fails out as the desired graph is empty, "desiredGraph":{"version":1,"project":{},"environments":[],"resources":[],"edges":[]}, this happens with or without any changes. Cant tell if its a bug or an issue with my config?


xeofd

Have updated to try out the changes, when I now run railway config plan it fails out as the desired graph is empty, "desiredGraph":{"version":1,"project":{},"environments":[],"resources":[],"edges":[]}, this happens with or without any changes. Cant tell if its a bug or an issue with my config?

This should not happen. Could you please send the full railway.ts contents as well as the output of railway config plan --json? Feel free to open a private support ticket with it if you need to.


futurepastori

This should not happen. Could you please send the full `railway.ts` contents as well as the output of `railway config plan --json`? Feel free to open a private support ticket with it if you need to.

2 months ago

okay, good to know, I have opened a private thread


Welcome!

Sign in to your Railway account to join the conversation.

Loading...