Environment Variables & Metadata
GameFlow automatically injects a set of environment variables and metadata into every game server at runtime. These are available without any additional configuration from the developer.
Environment Variables
These values are injected as standard environment variables into the game server container. They are available via process.env (JS/TS),Environment.GetEnvironmentVariable (C#/Unity), or equivalent in your runtime or engine.
| Variable | Type | Description | Example |
|---|---|---|---|
GAMEFLOW_REGION | string | The region where the game server is running. | us-east |
GAMEFLOW_DEFAULT_PORT | string | The primary/default port assigned to the game server container. | 7777 |
GAMEFLOW_{NAME}_PORT | string | One env var per additional port configured on the fleet, where {NAME} is the port label uppercased with spaces replaced by underscores. | 9090 |
Usage Examples
C# / Unity:
var region = Environment.GetEnvironmentVariable("GAMEFLOW_REGION");
var defaultPort = Environment.GetEnvironmentVariable("GAMEFLOW_DEFAULT_PORT");
// Server running in us-east on port 7777
Debug.Log($"Server running in {region} on port {defaultPort}");
var voiceChatPort = Environment.GetEnvironmentVariable("GAMEFLOW_VOICE_CHAT_PORT");
// Voice chat on port 9090
Debug.Log($"Voice chat on port {voiceChatPort}");
JS/TS:
const defaultPort = process.env.GAMEFLOW_DEFAULT_PORT;
const region = process.env.GAMEFLOW_REGION;
// Server running in us-east on port 7777
console.log(`Server running in ${region} on port ${defaultPort}`);
const voiceChatPort = process.env.GAMEFLOW_VOICE_CHAT_PORT;
// Voice chat on port 9090
console.log(`Voice chat on port ${voiceChatPort}`);
Additional Ports
When you configure additional ports on your fleet, GameFlow generates an environment variable for each one using the naming convention GAMEFLOW_{NAME}_PORT, where {NAME} is the port label uppercased with spaces replaced by underscores.
For example, a fleet configured with a default port and two additional ports labeled "voice chat" and "debug" would receive:
| Environment Variable | Value |
|---|---|
GAMEFLOW_DEFAULT_PORT | 7777 |
GAMEFLOW_VOICE_CHAT_PORT | 9090 |
GAMEFLOW_DEBUG_PORT | 9091 |
Metadata
Metadata is delivered via Agones GameServer annotations and can be read using the Agones SDK from within the game server process.
| Annotation | Type | Description | Example |
|---|---|---|---|
GAMEFLOW_PAYLOAD | string (JSON) | Optional JSON string with player or session data, passed at server creation or allocation time. | {"players": ["p1", "p2"]} |
Reading the Payload
The payload is stored as an annotation on the Agones GameServer object. Use the Agones SDK's GameServer() method to retrieve it.
C# / Unity:
var gs = await sdk.GameServer();
var payload = gs.ObjectMeta.Annotations["GAMEFLOW_PAYLOAD"];
if (!string.IsNullOrEmpty(payload)) {
var data = JsonConvert.DeserializeObject(payload);
Debug.Log(data); // {"players": ["p1", "p2"]}
}
JS/TS
const gs = await sdk.gameServer();
const payload = gs.objectMeta.annotationsMap.find(([key]) => key === "GAMEFLOW_PAYLOAD")?.[1];
if (payload) {
const data = JSON.parse(payload);
console.log(data); // {"players": ["p1", "p2"]}
}
Godot / GDScript:
var result = await AgonesSDK.gameserver().agones_response
if result[0]: # success
var gs = result[2]
var annotations = gs["object_meta"]["annotations"]
var payload = annotations.get("GAMEFLOW_PAYLOAD", "")
if payload != "":
var data = JSON.parse_string(payload)
print(data) # {"players": ["p1", "p2"]}
How Are These Different from Custom Environment Variables?
When creating a game in GameFlow, you can define custom environment variables that are baked into the container spec. These are static values used for configuration that doesn't change between sessions (e.g., LOG_LEVEL).
GameFlow-provided values are different:
- Automatically injected by the platform — no manual configuration needed.
GAMEFLOW_REGION,GAMEFLOW_DEFAULT_PORT, andGAMEFLOW_{NAME}_PORTare environment variables that reflect the runtime context of each server instance.GAMEFLOW_PAYLOADis not an environment variable — it is an AgonesGameServerannotation that carries dynamic, per-session data passed at allocation or server creation time. It must be read using the Agones SDK.
This separation allows developers to keep static configuration in the image while still receiving dynamic, per-instance and per-session data at runtime.