GS2-Guild 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
Configuration for controlling how distributed transactions are executed when processing guild operations. Supports auto-run, atomic commit, and async processing options.
changeNotificationNotificationSettingGuild Change Notification
Push notification sent via GS2-Gateway when guild information (display name, attributes, join policy, etc.) is updated. Allows guild members to receive real-time updates about changes to their guild.
joinNotificationNotificationSettingMember Join Notification
Push notification sent via GS2-Gateway when a new member joins the guild, either through direct join (open policy) or after approval of a join request. Enables existing members to be notified of new additions.
leaveNotificationNotificationSettingMember Leave Notification
Push notification sent via GS2-Gateway when a member leaves or is removed from the guild. Covers both voluntary departures and expulsions by guild masters.
changeMemberNotificationNotificationSettingMember Change Notification
Push notification sent via GS2-Gateway when a guild member’s information (role, metadata) is updated. Whether metadata changes trigger this notification can be controlled with changeMemberNotificationIgnoreChangeMetadata.
changeMemberNotificationIgnoreChangeMetadatabool?falseWhether to ignore changes in metadata when issuing notifications when member metadata is updated
receiveRequestNotificationNotificationSettingReceive Request Notification
Push notification sent via GS2-Gateway when the guild receives a new join request from a user. Allows guild masters and authorized members to be notified of pending requests that require approval.
removeRequestNotificationNotificationSettingRemove Request Notification
Push notification sent via GS2-Gateway when a guild join request is deleted, either by cancellation from the sender, rejection by the guild, or approval (which removes the request and adds the member).
createGuildScriptScriptSettingScript to execute when creating a Guild
Script Trigger Reference - createGuild
updateGuildScriptScriptSettingScript to execute when update a guild
Script Trigger Reference - updateGuild
joinGuildScriptScriptSettingScript to execute when joining a guild
Script Trigger Reference - joinGuild
receiveJoinRequestScriptScriptSettingScript to execute when receiving a guild join request
Script Trigger Reference - receiveJoinRequest
leaveGuildScriptScriptSettingScript to execute when leaving a guild
Script Trigger Reference - leaveGuild
changeRoleScriptScriptSettingScript to execute when changing the role assigned to a member
Script Trigger Reference - changeRole
deleteGuildScriptScriptSettingScript to execute when deleting a guild
Script Trigger Reference - deleteGuild
logSettingLogSettingLog Output Setting
Configuration for outputting log data of guild operations to GS2-Log. By specifying a GS2-Log namespace, API request and response logs for guild creation, joining, leaving, and role changes can be collected.

GetAttr

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

TypeDescription
ItemNamespaceNamespace created

Implementation Example

Type: GS2::Guild::Namespace
Properties:
  Name: namespace-0001
  Description: null
  TransactionSetting: 
    EnableAutoRun: true
    QueueNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001
  ChangeNotification: null
  JoinNotification: null
  LeaveNotification: null
  ChangeMemberNotification: null
  ChangeMemberNotificationIgnoreChangeMetadata: null
  ReceiveRequestNotification: null
  RemoveRequestNotification: null
  CreateGuildScript: null
  UpdateGuildScript: null
  JoinGuildScript: null
  ReceiveJoinRequestScript: null
  LeaveGuildScript: null
  ChangeRoleScript: null
  DeleteGuildScript: null
  LogSetting: 
    LoggingNamespaceId: grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/guild"
    "github.com/openlyinc/pointy"
)


SampleStack := core.NewStack()
guild.NewNamespace(
    &SampleStack,
    "namespace-0001",
    guild.NamespaceOptions{
        TransactionSetting: &core.TransactionSetting{
            QueueNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"),
        },
        LogSetting: &core.LogSetting{
            LoggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
        },
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        new \Gs2Cdk\Guild\Model\Namespace_(
            stack: $this,
            name: "namespace-0001",
            options: new \Gs2Cdk\Guild\Model\Options\NamespaceOptions(
                transactionSetting: new \Gs2Cdk\Core\Model\TransactionSetting(
                    new \Gs2Cdk\Core\Model\TransactionSettingOptions(
                        queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    )
                ),
                logSetting: new \Gs2Cdk\Core\Model\LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            )
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.guild.model.Namespace(
                this,
                "namespace-0001",
                new io.gs2.cdk.guild.model.options.NamespaceOptions()
                        .withTransactionSetting(new io.gs2.cdk.core.model.TransactionSetting(
                            new io.gs2.cdk.core.model.options.TransactionSettingOptions()
                                .withQueueNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001")
                        ))
                        .withLogSetting(new io.gs2.cdk.core.model.LogSetting(
                            "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                        ))
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Guild.Model.Namespace(
            stack: this,
            name: "namespace-0001",
            options: new Gs2Cdk.Gs2Guild.Model.Options.NamespaceOptions
            {
                transactionSetting = new Gs2Cdk.Core.Model.TransactionSetting(
                    options: new Gs2Cdk.Core.Model.TransactionSettingOptions
                    {
                        queueNamespaceId = "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    }
                ),
                logSetting = new Gs2Cdk.Core.Model.LogSetting(
                    loggingNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import guild from "@/gs2cdk/guild";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new guild.model.Namespace(
            this,
            "namespace-0001",
            {
                transactionSetting: new core.TransactionSetting(
                    {
                        queueNamespaceId: "grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001"
                    }
                ),
                logSetting: new core.LogSetting(
                    "grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"
                )
            }
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, guild

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        guild.Namespace(
            stack=self,
            name='namespace-0001',
            options=guild.NamespaceOptions(
                transaction_setting=core.TransactionSetting(
                    options=core.TransactionSettingOptions(
                        queue_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:queue:queue-0001',
                    )
                ),
                log_setting=core.LogSetting(
                    logging_namespace_id='grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001',
                ),
            ),
        )

print(SampleStack().yaml())  # Generate Template

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

CurrentGuildMaster

Currently active Guild Model master data

This master data describes the definitions of Guild 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
ItemCurrentGuildMasterUpdated master data of the currently active Guild Models

Implementation Example

Type: GS2::Guild::CurrentGuildMaster
Properties:
  NamespaceName: namespace-0001
  Mode: direct
  Settings: {
    "version": "2024-04-25",
    "guildModels": [
      {
        "name": "guild-0001",
        "defaultMaximumMemberCount": 10,
        "maximumMemberCount": 50,
        "inactivityPeriodDays": 10,
        "roles": [
          {
            "name": "master",
            "policyDocument": "{\\"Version\\": \\"2016-04-01\\", \\"Statements\\": [{\\"Effect\\": \\"Allow\\", \\"Actions\\": [\\"Gs2Guild:UpdateGuild\\"], \\"Resources\\": [\\"*\\"]}]}"
          },
          {
            "name": "member",
            "policyDocument": "{\\"Version\\": \\"2016-04-01\\", \\"Statements\\": [{\\"Effect\\": \\"Allow\\", \\"Actions\\": [\\"Gs2Guild:UpdateGuild\\"], \\"Resources\\": [\\"*\\"]}]}"
          }
        ],
        "guildMasterRole": "master",
        "guildMemberDefaultRole": "member",
        "rejoinCoolTimeMinutes": 1440
      },
      {
        "name": "guild-0002",
        "defaultMaximumMemberCount": 20,
        "maximumMemberCount": 40,
        "inactivityPeriodDays": 10,
        "roles": [
          {
            "name": "master",
            "policyDocument": "{\\"Version\\": \\"2016-04-01\\", \\"Statements\\": [{\\"Effect\\": \\"Allow\\", \\"Actions\\": [\\"Gs2Guild:UpdateGuild\\"], \\"Resources\\": [\\"*\\"]}]}"
          },
          {
            "name": "member",
            "policyDocument": "{\\"Version\\": \\"2016-04-01\\", \\"Statements\\": [{\\"Effect\\": \\"Allow\\", \\"Actions\\": [\\"Gs2Guild:UpdateGuild\\"], \\"Resources\\": [\\"*\\"]}]}"
          }
        ],
        "guildMasterRole": "master",
        "guildMemberDefaultRole": "member",
        "rejoinCoolTimeMinutes": 360
      }
    ]
  }
  UploadToken: null
import (
    "github.com/gs2io/gs2-golang-cdk/core"
    "github.com/gs2io/gs2-golang-cdk/guild"
)


SampleStack := core.NewStack()
guild.NewNamespace(
    &SampleStack,
    "namespace-0001",
    guild.NamespaceOptions{},
).MasterData(
    []guild.GuildModel{
        guild.NewGuildModel(
            "guild-0001",
            10,
            50,
            10,
            []guild.RoleModel{
                guild.NewRoleModel(
                    "master",
                    "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",
                    guild.RoleModelOptions{},
                ),
                guild.NewRoleModel(
                    "member",
                    "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",
                    guild.RoleModelOptions{},
                ),
            },
            "master",
            "member",
            1440,
            guild.GuildModelOptions{
            },
        ),
        guild.NewGuildModel(
            "guild-0002",
            20,
            40,
            10,
            []guild.RoleModel{
                guild.NewRoleModel(
                    "master",
                    "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",
                    guild.RoleModelOptions{},
                ),
                guild.NewRoleModel(
                    "member",
                    "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",
                    guild.RoleModelOptions{},
                ),
            },
            "master",
            "member",
            360,
            guild.GuildModelOptions{
            },
        ),
    },
)

println(SampleStack.Yaml())  // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
    function __construct() {
        parent::__construct();
        (new \Gs2Cdk\Guild\Model\Namespace_(
            stack: $this,
            name: "namespace-0001"
        ))->masterData(
            [
                new \Gs2Cdk\Guild\Model\GuildModel(
                    name:"guild-0001",
                    defaultMaximumMemberCount:10,
                    maximumMemberCount:50,
                    inactivityPeriodDays:10,
                    roles:[
                        new \Gs2Cdk\Guild\Model\RoleModel(
                            name: "master",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",    
                        ),
                        new \Gs2Cdk\Guild\Model\RoleModel(
                            name: "member",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",    
                        ),
                    ],
                    guildMasterRole:"master",
                    guildMemberDefaultRole:"member",
                    rejoinCoolTimeMinutes:1440
                ),
                new \Gs2Cdk\Guild\Model\GuildModel(
                    name:"guild-0002",
                    defaultMaximumMemberCount:20,
                    maximumMemberCount:40,
                    inactivityPeriodDays:10,
                    roles:[
                        new \Gs2Cdk\Guild\Model\RoleModel(
                            name: "master",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",    
                        ),
                        new \Gs2Cdk\Guild\Model\RoleModel(
                            name: "member",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}",    
                        ),
                    ],
                    guildMasterRole:"master",
                    guildMemberDefaultRole:"member",
                    rejoinCoolTimeMinutes:360
                )
            ]
        );
    }
}

print((new SampleStack())->yaml());  // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
    public SampleStack() {
        super();
        new io.gs2.cdk.guild.model.Namespace(
            this,
            "namespace-0001"
        ).masterData(
            Arrays.asList(
                new io.gs2.cdk.guild.model.GuildModel(
                    "guild-0001",
                    10,
                    50,
                    10,
                    Arrays.asList(
                        new io.gs2.cdk.guild.model.RoleModel(
                            "master",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                        new io.gs2.cdk.guild.model.RoleModel(
                            "member",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        )
                    ),
                    "master",
                    "member",
                    1440
                ),
                new io.gs2.cdk.guild.model.GuildModel(
                    "guild-0002",
                    20,
                    40,
                    10,
                    Arrays.asList(
                        new io.gs2.cdk.guild.model.RoleModel(
                            "master",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                        new io.gs2.cdk.guild.model.RoleModel(
                            "member",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        )
                    ),
                    "master",
                    "member",
                    360
                )
            )
        );
    }
}

System.out.println(new SampleStack().yaml());  // Generate Template
public class SampleStack : Gs2Cdk.Core.Model.Stack
{
    public SampleStack() {
        new Gs2Cdk.Gs2Guild.Model.Namespace(
            stack: this,
            name: "namespace-0001"
        ).MasterData(
            new Gs2Cdk.Gs2Guild.Model.GuildModel[] {
                new Gs2Cdk.Gs2Guild.Model.GuildModel(
                    name: "guild-0001",
                    defaultMaximumMemberCount: 10,
                    maximumMemberCount: 50,
                    inactivityPeriodDays: 10,
                    roles: new Gs2Cdk.Gs2Guild.Model.RoleModel[]
                    {
                        new Gs2Cdk.Gs2Guild.Model.RoleModel(
                            name: "master",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"    
                        ),
                        new Gs2Cdk.Gs2Guild.Model.RoleModel(
                            name: "member",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"    
                        )
                    },
                    guildMasterRole: "master",
                    guildMemberDefaultRole: "member",
                    rejoinCoolTimeMinutes: 1440
                ),
                new Gs2Cdk.Gs2Guild.Model.GuildModel(
                    name: "guild-0002",
                    defaultMaximumMemberCount: 20,
                    maximumMemberCount: 40,
                    inactivityPeriodDays: 10,
                    roles: new Gs2Cdk.Gs2Guild.Model.RoleModel[]
                    {
                        new Gs2Cdk.Gs2Guild.Model.RoleModel(
                            name: "master",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"    
                        ),
                        new Gs2Cdk.Gs2Guild.Model.RoleModel(
                            name: "member",
                            policyDocument: "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"    
                        )
                    },
                    guildMasterRole: "master",
                    guildMemberDefaultRole: "member",
                    rejoinCoolTimeMinutes: 360
                )
            }
        );
    }
}

Debug.Log(new SampleStack().Yaml());  // Generate Template
import core from "@/gs2cdk/core";
import guild from "@/gs2cdk/guild";

class SampleStack extends core.Stack
{
    public constructor() {
        super();
        new guild.model.Namespace(
            this,
            "namespace-0001",
        ).masterData(
            [
                new guild.model.GuildModel(
                    "guild-0001",
                    10,
                    50,
                    10,
                    [
                        new guild.model.RoleModel(
                            "master",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                        new guild.model.RoleModel(
                            "member",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                    ],
                    "master",
                    "member",
                    1440
                ),
                new guild.model.GuildModel(
                    "guild-0002",
                    20,
                    40,
                    10,
                    [
                        new guild.model.RoleModel(
                            "master",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                        new guild.model.RoleModel(
                            "member",
                            "{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}"        
                        ),
                    ],
                    "master",
                    "member",
                    360
                )
            ]
        );
    }
}

console.log(new SampleStack().yaml());  // Generate Template
from gs2_cdk import Stack, core, guild

class SampleStack(Stack):

    def __init__(self):
        super().__init__()
        guild.Namespace(
            stack=self,
            name="namespace-0001",
        ).master_data(
            guild_models=[
                guild.GuildModel(
                    name='guild-0001',
                    default_maximum_member_count=10,
                    maximum_member_count=50,
                    inactivity_period_days=10,
                    roles=[
                        guild.RoleModel(
                            name='master',
                            policy_document='{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}',        
                        ),
                        guild.RoleModel(
                            name='member',
                            policy_document='{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}',        
                        ),
                    ],
                    guild_master_role='master',
                    guild_member_default_role='member',
                    rejoin_cool_time_minutes=1440
                ),
                guild.GuildModel(
                    name='guild-0002',
                    default_maximum_member_count=20,
                    maximum_member_count=40,
                    inactivity_period_days=10,
                    roles=[
                        guild.RoleModel(
                            name='master',
                            policy_document='{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}',        
                        ),
                        guild.RoleModel(
                            name='member',
                            policy_document='{\\\"Version\\\": \\\"2016-04-01\\\", \\\"Statements\\\": [{\\\"Effect\\\": \\\"Allow\\\", \\\"Actions\\\": [\\\"Gs2Guild:UpdateGuild\\\"], \\\"Resources\\\": [\\\"*\\\"]}]}',        
                        ),
                    ],
                    guild_master_role='master',
                    guild_member_default_role='member',
                    rejoin_cool_time_minutes=360
                ),
            ],
        )

print(SampleStack().yaml())  # Generate Template

GuildModel

Guild Model

A Guild Model is an entity that sets the maximum number of people who can join the guild and the permission settings for each position within the guild.

TypeConditionRequiredDefaultValue LimitsDescription
guildModelIdstring
*
~ 1024 charsGuild Model GRN
* Set automatically by the server
namestring
~ 128 charsGuild Model name
Guild 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.
defaultMaximumMemberCountint
1 ~ 2147483646Default Maximum Member Count
The initial maximum number of members allowed when a new guild is created. This value is used as the starting currentMaximumMemberCount for new guilds. Can be increased later up to the maximumMemberCount limit through guild operations or acquire actions.
maximumMemberCountint
1 ~ 2147483646Maximum Member Count
The absolute upper limit for the number of members a guild can have. The guild’s currentMaximumMemberCount cannot exceed this value. This serves as a hard cap to prevent guilds from growing beyond the intended size.
inactivityPeriodDaysint71 ~ 365Inactivity Period Days
The number of days of guild master inactivity after which a new guild master is automatically selected from the remaining guild members. This prevents guilds from becoming unmanageable when the guild master stops playing.
rolesList<RoleModel>
1 ~ 10 itemsList of Role Models
The list of role definitions available within guilds of this type. Must include at least the roles referenced by guildMasterRole and guildMemberDefaultRole. Each role defines a unique set of permissions via a policy document. Up to 10 roles can be defined.
guildMasterRolestring
~ 128 charsGuild Master Role Name
The name of the role assigned to guild masters. Must reference a role defined in the roles list. Guild masters typically have full permissions to manage the guild, including approving join requests, expelling members, changing roles, and updating guild settings.
guildMemberDefaultRolestring
~ 128 charsDefault Member Role Name
The name of the role automatically assigned to new guild members when they join. Must reference a role defined in the roles list. This is the baseline permission set for regular members before any role changes by the guild master.
rejoinCoolTimeMinutesint00 ~ 2147483646Rejoin Cool Time (Minutes)
The cooldown period in minutes before a user can rejoin a guild after leaving. Set to 0 to allow immediate rejoining. This prevents abuse patterns where users repeatedly join and leave guilds.
maxConcurrentJoinGuildsint1 ~ 10Maximum Concurrent Guild Memberships
The maximum number of guilds of this type that a user can be a member of simultaneously. Allows for designs where players can belong to multiple guilds at the same time (e.g., a combat guild and a social guild). The value ranges from 1 to 10.
maxConcurrentGuildMasterCountint1 ~ 100Maximum Concurrent Guild Master Count
The maximum number of guild masters that can exist in a single guild at the same time. Allows for co-leadership designs where multiple players share guild master responsibilities and permissions. The value ranges from 1 to 100.

RoleModel

Role Model

The role model defines the role within the guild and sets the permissions for each role.

TypeConditionRequiredDefaultValue LimitsDescription
namestring
~ 128 charsRole Model name
Role 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.
policyDocumentstring
~ 10240 charsPolicy Document
A JSON-formatted policy document that defines the permissions for this role. Specifies which guild operations (such as accepting/rejecting join requests, expelling members, updating guild info, changing member roles) are allowed or denied for members assigned to this role.