The new IaC fails on all shared variables, even when it is linked to a valid project, in a valid environment, with a valid shared variable.
Example:
Project: Foo
Env: production
Shared value: BAR="some-value"
railway.ts:
import { defineRailway, github, project, service } from "railway/iac";
const REGION = "us-east4-eqdc4a";
export default defineRailway((ctx) => {
const baz = service("baz", {
env: {
BAR: ctx.shared.BAR
},
healthcheck: "/api/status",
replicas: { [REGION]: 1 },
source: github("some-repo", { branch: "main" }),
});
return project("Project Name", {
resources: [baz],
});
});
This fails with an error something like this:
node failed to evaluate IaC file.
file:///Users/user/dev/project/.railway/railway.ts?t=1787413491413:24
BAR: ctx.shared.BAR
TypeError: Cannot read properties of undefined (reading 'BAR')
at file:///Users/user/dev/project/.railway/railway.ts?t=1787413491413:24:37
at file:///Users/user/dev/project/[eval1]:10:56
Node.js v26.7.0
Claude suggested what looked like a horrible hack of creating a context if there wasn't one, but I've tested that and it seems to delete the shared variables in Railway in some cases.
This shouldn't fail as it is documented here: https://docs.railway.com/infrastructure-as-code/reference#environment-variables
This should pull from the project/environment and check that the variable exists (which it does) and then happily continue with the planning stage.
Unless I'm doing something seriously wrong, this is basically a showstopper for IaC since any secrets can't be managed outside of the Typescript file.
The new IaC fails on all shared variables, even when it is linked to a valid project, in a valid environment, with a valid shared variable.
Example:
Project: Foo
Env: production
Shared value: BAR="some-value"
railway.ts:
This fails with an error something like this:
Claude suggested what looked like a horrible hack of creating a context if there wasn't one, but I've tested that and it seems to delete the shared variables in Railway in some cases.
This shouldn't fail as it is documented here: https://docs.railway.com/infrastructure-as-code/reference#environment-variables
This should pull from the project/environment and check that the variable exists (which it does) and then happily continue with the planning stage.
Unless I'm doing something seriously wrong, this is basically a showstopper for IaC since any secrets can't be managed outside of the Typescript file.