

# Upload a script for Amazon GameLift Servers Realtime servers
Upload a Realtime script

When you're ready to deploy Amazon GameLift Servers Realtime for your game, upload completed Realtime server script files to Amazon GameLift Servers. Do this by creating an Amazon GameLift Servers script resource and specifying the location of your script files. You can also update server script files that are already deployed by uploading new files for an existing script resource.

When creating a script, you can choose the Node.js runtime version. Node.js 24 runs on Amazon Linux 2023, while Node.js 10 uses Amazon Linux 2. Amazon GameLift Servers automatically manages Node.js minor and patch version updates for new fleets. The runtime will remain unchanged for a fleet once it is created. If you would like to pick a specific minor and patch version of Node.js you can install it using an install script. See [Add an install script (optional)](#realtime-script-uploading-install-script).

When you create a new script resource, Amazon GameLift Servers assigns it a unique script ID (for example, `script-1111aaaa-22bb-33cc-44dd-5555eeee66ff`) and uploads a copy of the script files. Upload time depends on the size of your script files and on your connection speed.

After you create the script resource, Amazon GameLift Servers deploys the script with a new Amazon GameLift Servers Realtime fleet. Amazon GameLift Servers installs your server script onto each instance in the fleet, placing the script files in `/local/game`.

To troubleshoot fleet activation problems related to the server script, see [Debug managed EC2 fleets for Amazon GameLift Servers Realtime](fleets-creating-debug-realtime.md).

## Package script files


Your server script can include one or more files combined into a single .zip file for uploading. The .zip file must contain all files that your script needs to run.

You can store your zipped script files in either a local file directory or in an Amazon Simple Storage Service (Amazon S3) bucket.

### Add an install script (optional)


Similar to [ Add a build install script](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/gamelift-build-cli-uploading-install.html) for an Amazon GameLift Servers build, you can optionally add an install script to customize the runtime environment for your Realtime script. This feature is only available for scripts using Node.js version 24 and later.

To add an install script, include a file named `install.sh` in the root directory of your script .zip file. Amazon GameLift Servers will automatically detect and execute this script during fleet deployment.

**Note**  
The install script only executes during fleet creation. If you update an existing script using [UpdateScript](https://docs.aws.amazon.com/gameliftservers/latest/apireference/API_UpdateScript.html), the install script will not be executed on fleets that are already running. To apply install script changes, you must create a new fleet with the updated script.

**Example Install script example**  
This example `install.sh` file installs Node.js 24.10.0 to replace the default Node.js 24 runtime:  

```
#!/bin/bash

# Remove existing Node.js installation
sudo rm -rf /local/NodeJS/*

# Install Node.js v24.10.0
curl -L https://nodejs.org/dist/v24.10.0/node-v24.10.0-linux-x64.tar.xz | sudo tar -xJ -C /local/NodeJS --strip-components=1
```

# Upload script files from a local directory


If you have your script files stored locally, you can upload them to Amazon GameLift Servers from there. To create the script resource, use either the Amazon GameLift Servers console or the [AWS Command Line Interface (AWS CLI)](https://aws.amazon.com/cli/).

------
#### [  Amazon GameLift Servers console ]

**To create a script resource**

1. Open the [Amazon GameLift Servers console](https://console.aws.amazon.com/gamelift/).

1. In the navigation pane, choose **Hosting**, **Scripts**.

1. On the **Scripts** page, choose **Create script**.

1. On the **Create script** page, under **Script settings,** do the following:

   1. For **Name**, enter a script name.

   1. (Optional) For **Version**, enter version information. Because you can update the content of a script, version data can be helpful in tracking updates.

   1. For **Node.js version**, choose the runtime version of Node.js the server will run on.

   1. For **Script source**, choose **Upload a .zip file**.

   1. For **Script files**, choose **Choose file**, browse for the .zip file that contains your script, and then choose that file.

1. (Optional) Under **Tags**, add tags to the script by entering **Key** and **Value** pairs.

1. Choose **Create**.

   Amazon GameLift Servers assigns an ID to the new script and uploads the designated .zip file. You can view the new script, including its status, on the **Scripts** page.

------
#### [ AWS CLI ]

Use the [https://docs.aws.amazon.com/cli/latest/reference/gamelift/create-script.html](https://docs.aws.amazon.com/cli/latest/reference/gamelift/create-script.html) AWS CLI command to define the new script and upload your server script files.

**To create a script resource**

1. Place the .zip file into a directory where you can use the AWS CLI.

1. Open a command line window and switch to the directory where you placed the .zip file.

1. Enter the following **create-script** command and parameters. For the **--zip-file** parameter, be sure to add the string `fileb://` to the name of the .zip file. It identifies the file as binary so that Amazon GameLift Servers processes the compressed content.

   ```
   aws gamelift create-script \
       --name user-defined name of script \
       --script-version user-defined version info \
       --zip-file fileb://name of zip file \
       --node-js-version 10.x or 24.x \
       --region region name
   ```

   *Example*

   ```
   aws gamelift create-script \
       --name "My_Realtime_Server_Script_1" \
       --script-version "1.0.0" \
       --zip-file fileb://myrealtime_script_1.0.0.zip \
       --node-js-version 24.x \
       --region us-west-2
   ```

   In response to your request, Amazon GameLift Servers returns the new script object.

1. To view the new script, call `[describe-script](https://docs.aws.amazon.com/cli/latest/reference/gamelift/describe-script.html)`.

------

# Upload script files from Amazon S3


You can store your script files in an Amazon S3 bucket and upload them to Amazon GameLift Servers from there. When you create your script, you specify the S3 bucket location and Amazon GameLift Servers retrieves your script files from Amazon S3.

**To create a script resource**

1. **Store your script files in an S3 bucket.** Create a .zip file containing your server script files and upload it to an S3 bucket in an AWS account that you control. Take note of the object URI—you need this when creating an Amazon GameLift Servers script.
**Note**  
Amazon GameLift Servers doesn't support uploading from S3 buckets with names that contain a period (.).

1. **Give Amazon GameLift Servers access to your script files.** To create an AWS Identity and Access Management (IAM) role that allows Amazon GameLift Servers to access the S3 bucket containing your server script, follow the instructions in [ Set up an IAM service role for Amazon GameLift Servers](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/setting-up-role.html). After you create the new role, take note of its name, which you need when creating a script.

1. **Create a script.** Use the Amazon GameLift Servers console or the AWS CLI to create a new script record. To make this request, you must have the IAM `PassRole` permission, as described in [ IAM permission examples for Amazon GameLift Servers](https://docs.aws.amazon.com/gameliftservers/latest/developerguide/gamelift-iam-policy-examples.html).

------
#### [ Console ]

1. In the [Amazon GameLift Servers console](https://console.aws.amazon.com/gamelift), in the navigation pane, choose **Hosting**, **Scripts**.

1. On the **Scripts** page, choose **Create script**.

1. On the **Create script** page, under **Script settings**, do the following:

   1. For **Name**, enter a script name.

   1. (Optional) For **Version**, enter version information. Because you can update the content of a script, version data can be helpful in tracking updates.

   1. For **Node.js version**, choose the runtime version of Node.js the server will run on.

   1. For **Script source**, choose **Amazon S3 URI**.

   1. Enter the **S3 URI** of the script object that you uploaded to Amazon S3, and then choose the **Object version**. If you don't remember the Amazon S3 URI and object version, choose **Browse S3**, and then search for the script object.

1. (Optional) Under **Tags**, add tags to the script by entering **Key** and **Value** pairs.

1. Choose **Create**.

   Amazon GameLift Servers assigns an ID to the new script and uploads the designated .zip file. You can view the new script, including its status, on the **Scripts** page.

------
#### [ AWS CLI ]

Use the [https://docs.aws.amazon.com/cli/latest/reference/gamelift/create-script.html](https://docs.aws.amazon.com/cli/latest/reference/gamelift/create-script.html) AWS CLI command to define the new script and upload your server script files.

1. Open a command line window and switch to a directory where you can use the AWS CLI.

1. Enter the following **create-script** command and parameters. The **--storage-location** parameter specifies the Amazon S3 bucket location of your script files.

   ```
   aws gamelift create-script \
       --name [user-defined name of script] \
       --script-version [user-defined version info] \
       --storage-location "Bucket"=S3 bucket name,"Key"=name of zip file in S3 bucket,"RoleArn"=Access role ARN \
       --node-js-version 10.x or 24.x \
       --region region name
   ```

   *Example*

   ```
   aws gamelift create-script \
       --name "My_Realtime_Server_Script_1" \
       --script-version "1.0.0" \
       --storage-location "Bucket"="gamelift-script","Key"="myrealtime_script_1.0.0.zip","RoleArn"="arn:aws:iam::123456789012:role/S3Access" \
       --node-js-version 24.x \
       --region us-west-2
   ```

   In response to your request, Amazon GameLift Servers returns the new script object.

1. To view the new script, call [https://docs.aws.amazon.com/cli/latest/reference/gamelift/describe-script.html](https://docs.aws.amazon.com/cli/latest/reference/gamelift/describe-script.html).

------