The AWS::GameLift::Script resource 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.
IMPORTANT: The S3 permissions listed in the example are meant for testing purposes only. Restrict these permissions further for enhanced security.
To use awscc_gamelift_script to create a GameLift script:
resource "awscc_gamelift_script" "example" {
name = "example-script"
version = "v1.0.0"
storage_location = {
bucket = "your-s3-bucket"
key = "your-s3-key"
role_arn = awscc_iam_role.example.arn
}
}
resource "awscc_iam_role" "example" {
role_name = "gamelift-s3-access"
description = "This IAM role grants Amazon GameLift access to the S3 bucket containing script files."
assume_role_policy_document = data.aws_iam_policy_document.instance_assume_role_policy.json
managed_policy_arns = [aws_iam_policy.example.arn]
max_session_duration = 7200
path = "/"
tags = [
{
key = "Environment"
value = "Development"
},
{
key = "Modified By"
value = "AWSCC"
}
]
}
data "aws_iam_policy_document" "instance_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["gamelift.amazonaws.com"]
}
}
}
resource "aws_iam_policy" "example" {
name = "gamelift-s3-access-policy"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
Action = ["s3:*"]
Resource = "*"
},
]
})
}
storage_location
(Attributes) 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. (see below for nested schema)name
(String) A descriptive label that is associated with a script. Script names do not need to be unique.tags
(Attributes Set) An array of key-value pairs to apply to this resource. (see below for nested schema)version
(String) The version that is associated with a script. Version strings do not need to be unique.arn
(String) The Amazon Resource Name (ARN) that is assigned to a Amazon GameLift script resource and uniquely identifies it. ARNs are unique across all Regions. In a GameLift script ARN, the resource ID matches the Id value.creation_time
(String) A time stamp indicating when this data object was created. Format is a number expressed in Unix time as milliseconds (for example "1469498468.057").id
(String) Uniquely identifies the resource.script_id
(String) A unique identifier for the Realtime scriptsize_on_disk
(Number) The file size of the uploaded Realtime script, expressed in bytes. When files are uploaded from an S3 location, this value remains at "0".storage_location
Required:
bucket
(String) An Amazon S3 bucket identifier. This is the name of the S3 bucket.key
(String) The name of the zip file that contains the script files.role_arn
(String) The Amazon Resource Name (ARN) for an IAM role that allows Amazon GameLift to access the S3 bucket.Optional:
object_version
(String) The version of the file, if object versioning is turned on for the bucket. Amazon GameLift uses this information when retrieving files from your S3 bucket. To retrieve a specific version of the file, provide an object version. To retrieve the latest version of the file, do not set this parameter.tags
Required:
key
(String) The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length.value
(String) The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length.Import is supported using the following syntax:
$ terraform import awscc_gamelift_script.example <resource ID>