CreateScript
Creates a new script record for your Realtime Servers script. Realtime scripts are JavaScript that provide configuration settings and optional custom game logic for your game. The script is deployed when you create a Realtime Servers fleet to host your game sessions. Script logic is executed during an active game session.
To create a new script record, specify a script name and provide the script file(s). The script files and all dependencies must be zipped into a single file. You can pull the zip file from either of these locations:
-
A locally available directory. Use the ZipFile parameter for this option.
-
An Amazon Simple Storage Service (Amazon S3) bucket under your AWS account. Use the StorageLocation parameter for this option. You'll need to have an Identity Access Management (IAM) role that allows the Amazon GameLift service to access your S3 bucket.
If the call is successful, a new script record is created with a unique script ID. If the script file is provided as a local file, the file is uploaded to an Amazon GameLift-owned S3 bucket and the script record's storage location reflects this location. If the script file is provided as an S3 bucket, Amazon GameLift accesses the file at this storage location as needed for deployment.
Learn more
Amazon GameLift Realtime Servers
Set Up a Role for Amazon GameLift Access
Related actions
Request Syntax
{
"Name": "string
",
"StorageLocation": {
"Bucket": "string
",
"Key": "string
",
"ObjectVersion": "string
",
"RoleArn": "string
"
},
"Tags": [
{
"Key": "string
",
"Value": "string
"
}
],
"Version": "string
",
"ZipFile": blob
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
Note
In the following list, the required parameters are described first.
- Name
-
A descriptive label that is associated with a script. Script names do not need to be unique. You can use UpdateScript to change this value later.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- StorageLocation
-
The location of the Amazon S3 bucket where a zipped file containing your Realtime scripts is stored. The storage location must specify the Amazon S3 bucket name, the zip file name (the "key"), and a role ARN that allows Amazon GameLift to access the Amazon S3 storage location. The S3 bucket must be in the same Region where you want to create a new script. By default, Amazon GameLift uploads the latest version of the zip file; if you have S3 object versioning turned on, you can use the
ObjectVersion
parameter to specify an earlier version.Type: S3Location object
Required: No
- Tags
-
A list of labels to assign to the new script 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.
Type: Array of Tag objects
Array Members: Minimum number of 0 items. Maximum number of 200 items.
Required: No
- Version
-
Version information that is associated with a build or script. Version strings do not need to be unique. You can use UpdateScript to change this value later.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 1024.
Required: No
- ZipFile
-
A data object containing your Realtime scripts and dependencies as a zip file. The zip file can have one or multiple files. Maximum size of a zip file is 5 MB.
When using the AWS CLI tool to create a script, this parameter is set to the zip file name. It must be prepended with the string "fileb://" to indicate that the file data is a binary object. For example:
--zip-file fileb://myRealtimeScript.zip
.Type: Base64-encoded binary data object
Length Constraints: Maximum length of 5000000.
Required: No
Response Syntax
{
"Script": {
"CreationTime": number,
"Name": "string",
"ScriptArn": "string",
"ScriptId": "string",
"SizeOnDisk": number,
"StorageLocation": {
"Bucket": "string",
"Key": "string",
"ObjectVersion": "string",
"RoleArn": "string"
},
"Version": "string"
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- Script
-
The newly created script record with a unique script ID and ARN. The new script's storage location reflects an Amazon S3 location: (1) If the script was uploaded from an S3 bucket under your account, the storage location reflects the information that was provided in the CreateScript request; (2) If the script file was uploaded from a local zip file, the storage location reflects an S3 location controls by the Amazon GameLift service.
Type: Script object
Errors
For information about the errors that are common to all actions, see Common Errors.
- ConflictException
-
The requested operation would cause a conflict with the current state of a service resource associated with the request. Resolve the conflict before retrying this request.
HTTP Status Code: 400
- InternalServiceException
-
The service encountered an unrecoverable internal failure while processing the request. Clients can retry such requests immediately or after a waiting period.
HTTP Status Code: 500
- InvalidRequestException
-
One or more parameter values in the request are invalid. Correct the invalid parameter values before retrying.
HTTP Status Code: 400
- TaggingFailedException
-
The requested tagging operation did not succeed. This may be due to invalid tag format or the maximum tag limit may have been exceeded. Resolve the issue before retrying.
HTTP Status Code: 400
- UnauthorizedException
-
The client failed authentication. Clients should not retry such requests.
HTTP Status Code: 400
Examples
Create a script from a local zip file
This example creates a script record and uploads a Realtime script from a zip file that is stored locally.
Sample Request
{
"Name": "My_Realtime_Script_1",
"Version": "1.0.1",
"ZipFile": <zip file data>
}
CLI syntax:
aws gamelift create-script
--name "My_Realtime_Script_1"
--script-version "1.0.1"
--zip-file fileb://myrealtime_script.zip
Sample Response
{
"Script": {
"CreationTime": 1496708916.18,
"Name": "My_Realtime_Script_1",
"ScriptArn": "arn:aws:gamelift:us-west-2::script/script-1111aaaa-22bb-33cc-44dd-5555eeee66ff",
"ScriptId": "script-1111aaaa-22bb-33cc-44dd-5555eeee66ff",
"SizeOnDisk": 9000,
"StorageLocation": {
"Bucket": "prod-gamescale-scripts-us-west-2",
"Key": "123456789012/script-1111aaaa-22bb-33cc-44dd-5555eeee66ff"
},
"Version": "1.0.1"
}
}
Create a script with a file in Amazon S3
This example creates a script record and uploads a Realtime server script from a zip file that is stored in an Amazon S3 account.
Sample Request
{
"Name": "My_Realtime_Script_2",
"Version": "12345.678",
"StorageLocation": {
"Bucket": "my_realtime_script_files",
"Key": "myRealtimeScript.zip",
"RoleArn": "arn:aws:iam::111122223333:role/GameLiftAccess"
}
}
CLI syntax:
aws gamelift create-script
--name "My_Realtime_Script_2"
--script-version "12345.678"
--storage-location
"Bucket=my_realtime_script_files,
Key=myRealtimeScript.zip,
RoleArn=arn:aws:iam::123456789012:role/GameLiftAccess"
Sample Response
{
"Script": {
"CreationTime": 1496708916.18,
"Name": "My_Realtime_Script_2",
"ScriptId": "script-1111aaaa-22bb-33cc-44dd-5555eeee66ff",
"ScriptArn": "arn:aws:gamelift:us-west-2::script/script-1111aaaa-22bb-33cc-44dd-5555eeee66ff",
"SizeOnDisk": 0,
"StorageLocation": {
"Bucket": "my_realtime_script_files",
"Key": "myRealtimeScript.zip"
"RoleArn": "arn:aws:iam::111122223333:role/GameLiftAccess"
"ObjectVersion": null
},
"Version": "12345.678"
}
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: