GS2-Version Deploy/CDK Reference

The template format used when creating stacks with GS2-Deploy, and implementation examples of template output in various languages using CDK

Entities

Resources targeted by the Deploy operation

Namespace

Namespace

A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts. Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the namespace differs, the data is treated as a completely independent data space.

Therefore, you must create a namespace before you can start using each service.

Request

Resource creation and update requests

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
descriptionstring~ 1024 charsDescription
transactionSettingTransactionSettingTransaction Setting
assumeUserIdstring
~ 1024 charsGS2-Identifier user GRN to be promoted if the version check is passed
acceptVersionScriptScriptSettingScript to run when a version is accepted/approved
Script Trigger Reference - acceptVersion
checkVersionTriggerScriptIdstring~ 1024 charsGS2-Script script GRN to perform version checking process
logSettingLogSettingLog Output Setting

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::Version::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  AssumeUserId: grn:gs2::YourOwnerId:identifier:user:user-0001
  AcceptVersionScript: null
  CheckVersionTriggerScriptId: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001

TransactionSetting

Transaction Setting

Transaction Setting controls how transactions are executed, including their consistency, asynchronous processing, and conflict avoidance mechanisms. Combining features like AutoRun, AtomicCommit, asynchronous execution using GS2-Distributor, batch application of script results, and asynchronous Acquire Actions via GS2-JobQueue enables robust transaction management tailored to game logic.

TypeConditionRequiredDefaultValue LimitsDescription
enableAutoRunboolfalseWhether to automatically execute issued transactions on the server side
enableAtomicCommitbool{enableAutoRun} == truefalseWhether to commit the execution of transactions atomically
* Applicable only if enableAutoRun is true
transactionUseDistributorbool{enableAtomicCommit} == truefalseWhether to execute transactions asynchronously
* Applicable only if enableAtomicCommit is true
commitScriptResultInUseDistributorbool{transactionUseDistributor} == truefalseWhether to execute the commit processing of the script result asynchronously
* Applicable only if transactionUseDistributor is true
acquireActionUseJobQueuebool{enableAtomicCommit} == truefalseWhether to use GS2-JobQueue to execute the acquire action
* Applicable only if enableAtomicCommit is true
distributorNamespaceIdstring“grn:gs2:{region}:{ownerId}:distributor:default”~ 1024 charsGS2-Distributor Namespace GRN used to execute transactions
queueNamespaceIdstring“grn:gs2:{region}:{ownerId}:queue:default”~ 1024 charsGS2-JobQueue Namespace GRN used to execute transactions

ScriptSetting

Script Setting

In GS2, you can associate custom scripts with microservice events and execute them. This model holds the settings for triggering script execution.

There are two main ways to execute a script: synchronous execution and asynchronous execution. Synchronous execution blocks processing until the script has finished executing. Instead, you can use the script’s execution results to halt API execution or control the API’s response content.

In contrast, asynchronous execution does not block processing until the script has finished executing. However, because the script result cannot be used to stop the API execution or modify the API response, asynchronous execution does not affect the API response flow and is generally recommended.

There are two types of asynchronous execution methods: GS2-Script and Amazon EventBridge. By using Amazon EventBridge, you can write processing in languages other than Lua.

TypeConditionRequiredDefaultValue LimitsDescription
triggerScriptIdstring~ 1024 charsGS2-Script script GRN executed synchronously when the API is executed
Must be specified in GRN format starting with “grn:gs2:”.
doneTriggerTargetTypeString Enum
enum {
  “none”,
  “gs2_script”,
  “aws”
}
“none”How to execute asynchronous scripts
Specifies the type of script to use for asynchronous execution.
You can choose from “Do not use asynchronous execution (none)”, “Use GS2-Script (gs2_script)”, and “Use Amazon EventBridge (aws)”.
DefinitionDescription
“none”None
“gs2_script”GS2-Script
“aws”Amazon EventBridge
doneTriggerScriptIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-Script script GRN for asynchronous execution
Must be specified in GRN format starting with “grn:gs2:”.
* Applicable only if doneTriggerTargetType is “gs2_script”
doneTriggerQueueNamespaceIdstring{doneTriggerTargetType} == “gs2_script”~ 1024 charsGS2-JobQueue namespace GRN to execute asynchronous execution scripts
If you want to execute asynchronous execution scripts via GS2-JobQueue instead of executing them directly, specify the GS2-JobQueue namespace GRN.
There are not many cases where GS2-JobQueue is required, so you generally do not need to specify it unless you have a specific reason.
* Applicable only if doneTriggerTargetType is “gs2_script”

LogSetting

Log Output Setting

Log Output Setting defines how log data is exported. This type holds the GS2-Log namespace identifier (Namespace ID) used to export log data. Specify the GS2-Log namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId). Configuring this setting ensures that log data for API requests and responses occurring within the specified namespace is output to the target GS2-Log namespace. GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.

TypeConditionRequiredDefaultValue LimitsDescription
loggingNamespaceIdstring
~ 1024 charsGS2-Log namespace GRN to output logs
Must be specified in GRN format starting with “grn:gs2:”.

CurrentVersionMaster

Currently active Version Model master data

This master data describes the definitions of Version Models currently active within the namespace. GS2 uses JSON format files for managing master data. By uploading these files, the master data settings are updated on the server.

To create JSON files, GS2 provides a master data editor within the management console. Additionally, you can create tools better suited for game operations and export JSON files in the appropriate format.

Request

Resource creation and update requests

TypeConditionRequiredDefaultValue LimitsDescription
namespaceNamestring
~ 128 charsNamespace name
Namespace-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
modeString Enum
enum {
  “direct”,
  “preUpload”
}
“direct”Update mode
DefinitionDescription
“direct”Directly update master data
“preUpload”Upload master data and then update
settingsstring{mode} == “direct”
✓*
~ 5242880 charsMaster Data
* Required if mode is “direct”
uploadTokenstring{mode} == “preUpload”
✓*
~ 1024 charsToken obtained by pre-upload
Used to apply the uploaded master data.
* Required if mode is “preUpload”

GetAttr

Resource creation results that can be retrieved using the !GetAttr tag

TypeDescription
ItemCurrentVersionMasterUpdated master data of the currently active Version Models

Implementation Example

Type: GS2::Version::CurrentVersionMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2019-10-09",
    "versionModels": [
      {
        "name": "app",
        "scope": "passive",
        "type": "simple",
        "metadata": "APP",
        "warningVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "errorVersion":
          {
            "major": 1,
            "minor": 1,
            "micro": 1
          }
      },
      {
        "name": "asset",
        "scope": "passive",
        "type": "simple",
        "metadata": "ASSET",
        "warningVersion":
          {
            "major": 3,
            "minor": 3,
            "micro": 3
          },
        "errorVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "needSignature": true,
        "signatureKeyId": "grn:gs2:ap-northeast-1:YourOwnerId:key:namespace-0001:key:key-0001"
      },
      {
        "name": "eula",
        "scope": "active",
        "type": "simple",
        "metadata": "EULA",
        "currentVersion":
          {
            "major": 2,
            "minor": 2,
            "micro": 2
          },
        "warningVersion":
          {
            "major": 4,
            "minor": 4,
            "micro": 4
          },
        "errorVersion":
          {
            "major": 3,
            "minor": 3,
            "micro": 3
          }
      }
    ]
  }
  UploadToken: null

VersionModel

Version Model

You can set a warning version that accepts login but notifies you that you can upgrade, and an error version that does not accept login.

You can specify whether or not to have the client declare the current version with or without a signature. If you select signed, the client will not be able to declare a false version.

TypeConditionRequiredDefaultValue LimitsDescription
versionModelIdstring
*
~ 1024 charsVersion Model GRN
* Set automatically by the server
namestring
~ 128 charsVersion Model name
Version Model-specific name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.).
metadatastring~ 2048 charsMetadata
Arbitrary values can be set in the metadata.
Since they do not affect GS2’s behavior, they can be used to store information used in the game.
scopeString Enum
enum {
  “passive”,
  “active”
}
Type of version value used for judgment
DefinitionDescription
“passive”Sent by Client
“active”Version explicitly approved in the past
typeString Enum
enum {
  “simple”,
  “schedule”
}
“simple”Version Check Mode
DefinitionDescription
“simple”Simple
“schedule”Schedule Change
currentVersionVersion{type} == “simple” and {scope} == “active”
✓*
Current Version
* Required if type is “simple” and scope is “active”
warningVersionVersion{type} == “simple”
✓*
Version that prompts for version upgrade
* Required if type is “simple”
errorVersionVersion{type} == “simple”
✓*
Version that is determined to be an error by the version check
* Required if type is “simple”
scheduleVersionsList<ScheduleVersion>{type} == “schedule”0 ~ 10 itemsList of Version check content that switches over time series
* Applicable only if type is “schedule”
needSignaturebool{scope} == “passive”
✓*
Whether the version value to be determined requires signature verification
* Required if scope is “passive”
signatureKeyIdstring{needSignature}
✓*
~ 1024 charsEncryption Key GRN
* Required if needSignature is “true”
approveRequirementString Enum
enum {
  “required”,
  “optional”
}
{scope} == “active”“required”Requirement for approval
DefinitionDescription
“required”Approval required
“optional”Approval optional
* Applicable only if scope is “active”

Version

Version

TypeConditionRequiredDefaultValue LimitsDescription
majorint
0 ~ 2147483646Major version
minorint
0 ~ 2147483646Minor version
microint
0 ~ 2147483646Micro version

ScheduleVersion

Version that switches in chronological order

TypeConditionRequiredDefaultValue LimitsDescription
currentVersionVersion
Current Version
warningVersionVersion
Version that prompts for version upgrade
errorVersionVersion
Version that is determined to be an error by the version check
scheduleEventIdstring~ 1024 charsGS2-Schedule event GRN that enables version check