GS2-AdReward 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
admobAdMobAdMob settings
Manages settings and parameters related to ads.
unityAdUnityAdUnity Ads settings
Manages settings and parameters related to ads.
appLovinMaxesList<AppLovinMax>0 ~ 10 itemsAppLovin MAX settings
Manages settings and parameters related to ads.
acquirePointScriptScriptSettingScript setting to be executed when points are acquired
Script Trigger Reference - acquirePoint
consumePointScriptScriptSettingScript setting to be executed when points are consumed
Script Trigger Reference - consumePoint
changePointNotificationNotificationSetting
Push notification when point changes
This is a push notification setting when the point changes.
This setting holds the information necessary to notify the game client when the point changes.
If you do not make this setting, the points you earn will not be reflected in the game immediately.
logSettingLogSettingLog Output Settings
Manages log output setting. This type holds the GS2-Log namespace information used to output log data.

GetAttr

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

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::AdReward::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: null
  Admob: 
    AllowAdUnitIds: 
    - 1
    - 2
    - 3
  UnityAd: 
    Keys: 
    - key-0001
    - key-0002
  AppLovinMaxes: []
  AcquirePointScript: null
  ConsumePointScript: null
  ChangePointNotification: 
    GatewayNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:gateway:namespace-0001
  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”

NotificationSetting

Push Notification Settings

This is a setting for sending push notifications when an event occurs in a GS2 microservice. The push notification here refers to the processing via the WebSocket interface provided by GS2-Gateway, and is different from the push notification of a smartphone. For example, when a matchmaking is completed or a friend request is received, the GS2-Gateway can send a push notification via the WebSocket interface, and the game client can detect the change of the state.

GS2-Gateway’s push notifications can be used to forward notifications to mobile push notification services when the destination device is offline. By properly utilizing mobile push notifications, you can implement a flow in which players are notified even if they exit the game during matchmaking and later return to it.

TypeConditionRequiredDefaultValue LimitsDescription
gatewayNamespaceIdstring“grn:gs2:{region}:{ownerId}:gateway:default”~ 1024 charsGS2-Gateway namespace to use for push notifications
Specify the GS2-Gateway namespace ID in GRN format starting with “grn:gs2:”.
enableTransferMobileNotificationbool?falseWhether to forward the notification as a mobile push notification
When this notification is sent and the destination device is offline, specify whether to forward it as a mobile push notification.
soundstring{enableTransferMobileNotification} == true~ 1024 charsSound file name to be used for mobile push notifications
The sound file name specified here is used when sending mobile push notifications, and you can send notifications with a special sound.
* Applicable only if enableTransferMobileNotification is true
enableString Enum
enum {
  “Enabled”,
  “Disabled”
}
“Enabled”Whether to enable push notifications
DefinitionDescription
“Enabled”Enabled
“Disabled”Disabled

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:”.

AdMob

AdMob settings

Stores a list of allowed ad unit IDs and uses it to verify AdMob’s viewing completion Webhook.

TypeConditionRequiredDefaultValue LimitsDescription
allowAdUnitIdsList<string>
1 ~ 10 itemsList of allowed ad unit IDs
Used to verify the ad unit ID included in the ad viewing completion callback from AdMob.
The ad unit IDs included in this list are used to verify that the ad viewing was completed properly in the application or game.
By checking whether the ad unit ID included in the notification of ad viewing completion sent from the AdMob platform is in this list, you can accept only legitimate ad viewing events and prevent invalid requests and spam.

UnityAd

Unity Ads settings

Used to store the Unity Ads-related cryptographic keys used by the application or game. The cryptographic keys are issued by Unity Ads and are used to verify the completion of ad viewing.

TypeConditionRequiredDefaultValue LimitsDescription
keysList<string>0 ~ 10 itemsList of cryptographic keys
Stores a list of cryptographic keys issued by Unity Ads.
These keys are used to communicate with the Unity Ads ad platform and to verify ad events.

Encryption keys can be obtained from the Unity Dashboard.
Each key in the list is required to verify the completion of ad viewing.

AppLovinMax

AppLovin MAX settings

Stores an allowed ad unit ID and uses it to verify the AppLovin MAX viewing completion Webhook.

TypeConditionRequiredDefaultValue LimitsDescription
allowAdUnitIdstring
~ 16 charsAllowed Ad Unit ID
Used to verify the ad_unit_id included in the AppLovin MAX ad viewing completion callback.
The ad viewing event is accepted only when the ad_unit_id in the callback matches the configured ad unit ID.
This prevents unauthorized callbacks, invalid requests, and fraudulent reward claims from unregistered ad units.
eventKeystring
~ 128 charsAppLovin Event Key
Used to verify that the completion callback from AppLovin MAX is accessed from the appropriate source.