Amazon GameLift
Developer Guide (Version )

Upload Build Files to Amazon GameLift

Once your game server files are packaged, you must deliver them to Amazon GameLift for hosting. This is done by creating an Amazon GameLift build. You have two options for creating a build:

  • Create a build with game build files that are stored in a directory. This is the simplest method.

  • Create a build with game build files that are stored an Amazon S3 account.

When you create a build, a new game build record is created. This record contains a unique build ID (example: build-75bf99cd-2dd8-2039-8074-ab24da1f80e4), creation time stamp, uploaded file size, status, and other metadata. The build is immediately placed in Initialized status and remains there until Amazon GameLift acquires the build files. Once the game server files are successfully acquired, the build moves to Ready status.

Once a build is in Ready status, you can deploy it with a new Amazon GameLift fleet. When you create a fleet for the build, Amazon GameLift sets up new fleet instances and installs the game server build on each instance. Build files are installed in the following locations:

  • For Windows fleets: C:\game

  • For Linux fleets: /local/game

To troubleshoot fleet activation problems that might be related to build installation, you can remotely access a fleet instance for debugging. See Remotely Access Fleet Instances.

Create a Build with Files in a Directory

To create a game build with packaged game server files stored in any location, including a local directory, use the AWS Command Line Interface (AWS CLI) command upload-build. This command creates a new build record in Amazon GameLift and uploads files from a location you specify.

  1. Send an upload request. In a command line window, type the following command and parameters.

    aws gamelift upload-build --operating-system [supported OS] --build-root [build path] --name [user-defined name of build] --build-version [user-defined build number] --region [region name]
    --build-root

    The directory path of your build files.

    --operating-system

    The operating system that all server executables in the build run on. All fleets created with this build automatically use this OS. Valid values are WINDOWS_2012 and AMAZON_LINUX. This parameter is optional. If an operating system is not specified, Amazon GameLift uses the default value (WINDOWS_2012). This value cannot be changed later.

    --region

    Name of the region that you want to create your build in. You must create the build in the region that you want to deploy fleets in. To deploy in multiple regions, you must create a build and upload files for each region. If you configured your AWS CLI with a default region, you can omit this parameter.

    Note

    If you work in multiple regions, it is always a good idea to check your current default region. Use the AWS CLI command configure get (aws configure get region) to see your current default region. Use the command configure set (aws configure set region [region name]) to set a default region.

    --name and --build-version

    Use these parameters to describe your build. These metadata values can be changed later using update-build (or the AWS SDK operation UpdateBuild).

    In response to your upload request, the Amazon GameLift service provides upload progress, and on a successful upload returns the new build record ID. Upload time depends on the size of your game files and the connection speed.

    Examples:

    aws gamelift upload-build --operating-system AMAZON_LINUX --build-root ~/mygame --name "My Game Nightly Build" --build-version "build 255" --region us-west-2
    aws gamelift upload-build --operating-system WINDOWS_2012 --build-root "C:\mygame" --name "My Game Nightly Build" --build-version "build 255" --region us-west-2
  2. Check build status. View the new build record, including current status, using describe-build (or DescribeBuild). You can also view status on the Amazon GameLift console.

    In a command line window, type the following command and parameters.

    aws gamelift describe-build --build-id [build ID returned with the upload request] --region [region name]

    Example:

    aws gamelift describe-build --build-id "build-75bf99cd-2dd8-2039-8074-ab24da1f80e4" --region us-west-2

    In response to your request, the Amazon GameLift service returns the requested build record. This record contains a set of build metadata including status, size of the uploaded files, and a creation time stamp.

Create a Build with Files in Amazon S3

To create a game build with packaged game server files stored in an Amazon S3 bucket in your AWS account, use the AWS CLI command create-build. This operation creates a new build in Amazon GameLift and acquires your build files from the Amazon S3 bucket that you specify.

  1. Store your build files in Amazon S3. Create a .zip file containing the packaged build files and upload it to an Amazon S3 bucket in your AWS account. Take note of the bucket label and the file name; you'll need these when creating an Amazon GameLift build.

  2. Give Amazon GameLift access to your build files. Using the AWS Identity and Access Management(IAM) service, set up a new role that allows Amazon GameLift to access to your build files. This step requires the following tasks: (1) create the role and give it a name, (2) attach a trust relationship policy that allows Amazon GameLift to assume the role, and (3) attach an access policy that limits the role's access. You can limit access as tightly as you need to, even to one specific file in a bucket. Once you've created the role, take note of the new role's Amazon Resource Name (ARN), which you'll need when creating a build.

    Note

    You can use the IAM console or AWS CLI tool to set up the role. If you use the console Create Role wizard, the easiest method is to create a simple AWS service role (select any service and do not attach a policy). Then add the trust relationship and access policy (shown as follows) to the newly created role. See the IAM user guide topic Creating a Role for help using the IAM console or AWS CLI tool.

    Attach the following policies to the role:

    • Trust relationship limited to Amazon GameLift:

      { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "gamelift.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }
    • Inline policy limiting access to read-only rights for a specified S3 bucket:

      { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:GetObject", "s3:GetObjectVersion", "s3:GetObjectMetadata" ], "Resource": "arn:aws:s3:::[BucketName]/*", "Effect": "Allow" } ] }
  3. Send a request to create a new build. Use the AWS CLI command create-build (or the AWS SDK operation CreateBuild) to create a new build record and tell Amazon GameLift where your build files are stored. In this request, you must specify an Amazon S3 location, including the following information (which you collected when setting up your bucket and access role):

    • Bucket: The name of the bucket that contains your build. Example: "my_build_files".

       

    • Key: The name of the .zip file that contains your build files. Example: "mygame_build_7.0.1, 7.0.2".

       

    • Role ARN: The ARN assigned to the access role you created. Example: "arn:aws:iam::111122223333:role/GameLiftAccess".

    In a command line window, type the following command and parameters.

    aws gamelift create-build --operating-system [supported OS] --storage-location "Bucket=[S3 bucket label],Key=[Build zip file name],RoleArn=[Access role ARN]" --name [user-defined name of build] --build-version [user-defined build number] --region [region name]

    Example:

    aws gamelift create-build --operating-system WINDOWS_2012 --storage-location "Bucket=gamelift-builds,Key=MyGame.zip,RoleArn=arn:aws:iam::401680102694:role/gamelift" --name "My Game Nightly Build" --build-version "build 255" --region us-west-2

    In response to your request, the Amazon GameLift service returns the newly created build record.

Update Your Build Files

Once an Amazon GameLift build has been created, the build files associated with it cannot be changed. Instead, you must create a new Amazon GameLift build for each new set of files. If you provide build files using the upload-build command, you don't need to do anything special because Amazon GameLift automatically creates a new build record for each request. If you provide build files using the create-build command, upload a new build .zip file with a different name to Amazon S3 and create a build by referencing the new file name.

Try these tips for deploying updated builds:

  • Use aliases to seamlessly transfer players to a new game build. When integrating your game client with Amazon GameLift, specify a fleet alias instead of a fleet ID. That way you can move players to a new build in just three steps: (1) Create the new build. (2) Create a fleet to deploy the new build. (3) Change the alias target from the old fleet to the new fleet. For more information, see Working with Aliases.

  • Set up automated build updates. Follow the GameDev blog post Automating Deployments to Amazon GameLift, with sample scripts, to incorporate Amazon GameLift deployments into your build system.