createBuild method

Future<CreateBuildOutput> createBuild({
  1. String? name,
  2. OperatingSystem? operatingSystem,
  3. S3Location? storageLocation,
  4. List<Tag>? tags,
  5. String? version,
})

Creates a new Amazon GameLift build resource for your game server binary files. Game server binaries must be combined into a zip file for use with Amazon GameLift. The CreateBuild operation can used in the following scenarios:

  • To create a new game build with build files that are in an S3 location under an AWS account that you control. To use this option, you must first give Amazon GameLift access to the S3 bucket. With permissions in place, call CreateBuild and specify a build name, operating system, and the S3 storage location of your game build.
  • To directly upload your build files to a GameLift S3 location. To use this option, first call CreateBuild and specify a build name and operating system. This operation creates a new build resource and also returns an S3 location with temporary access credentials. Use the credentials to manually upload your build files to the specified S3 location. For more information, see Uploading Objects in the Amazon S3 Developer Guide. Build files can be uploaded to the GameLift S3 location once only; that can't be updated.
If successful, this operation creates a new build resource with a unique build ID and places it in INITIALIZED status. A build must be in READY status before you can create fleets with it.

Learn more

Uploading Your Game

Create a Build with Files in Amazon S3

Related operations

May throw UnauthorizedException. May throw InvalidRequestException. May throw ConflictException. May throw TaggingFailedException. May throw InternalServiceException.

Parameter name : A descriptive label that is associated with a build. Build names do not need to be unique. You can use UpdateBuild to change this value later.

Parameter operatingSystem : The operating system that the game server binaries are built to run on. This value determines the type of fleet resources that you can use for this build. If your game build contains multiple executables, they all must run on the same operating system. If an operating system is not specified when creating a build, Amazon GameLift uses the default value (WINDOWS_2012). This value cannot be changed later.

Parameter storageLocation : The location where your game build files are stored. Use this parameter only when creating a build using files that are stored in an S3 bucket that you own. Identify an S3 bucket name and key, which must in the same Region where you're creating a build. This parameter must also specify the ARN for an IAM role that you've set up to give Amazon GameLift access your S3 bucket. To call this operation with a storage location, you must have IAM PassRole permission. For more details on IAM roles and PassRole permissions, see Set up a role for GameLift access.

Parameter tags : A list of labels to assign to the new build resource. Tags are developer-defined key-value pairs. Tagging AWS resources are useful for resource management, access management and cost allocation. For more information, see Tagging AWS Resources in the AWS General Reference. Once the resource is created, you can use TagResource, UntagResource, and ListTagsForResource to add, remove, and view tags. The maximum tag limit may be lower than stated. See the AWS General Reference for actual tagging limits.

Parameter version : Version information that is associated with a build or script. Version strings do not need to be unique. You can use UpdateBuild to change this value later.

Implementation

Future<CreateBuildOutput> createBuild({
  String? name,
  OperatingSystem? operatingSystem,
  S3Location? storageLocation,
  List<Tag>? tags,
  String? version,
}) async {
  _s.validateStringLength(
    'name',
    name,
    1,
    1024,
  );
  _s.validateStringLength(
    'version',
    version,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'GameLift.CreateBuild'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      if (name != null) 'Name': name,
      if (operatingSystem != null)
        'OperatingSystem': operatingSystem.toValue(),
      if (storageLocation != null) 'StorageLocation': storageLocation,
      if (tags != null) 'Tags': tags,
      if (version != null) 'Version': version,
    },
  );

  return CreateBuildOutput.fromJson(jsonResponse.body);
}