GS2-Deploy 템플릿 파일 사양
GS2-Deploy에서 스택을 생성할 때 사용하는 템플릿 파일의 서식 사양입니다. JSON 형식 또는 YAML 형식으로 작성할 수 있습니다.
섹션 종류
템플릿은 다음과 같은 섹션으로 구성됩니다.
| 섹션 | 필수 | 설명 |
|---|---|---|
| GS2TemplateFormatVersion | ✓ | 템플릿의 형식을 지정합니다. 현재는 2019-05-01만 정의할 수 있습니다. |
| Description | 템플릿에 관한 설명 등을 기입할 수 있습니다. | |
| Globals | Alias 속성(문자열 치환 지정)을 정의하는 섹션입니다. | |
| Resources | ✓ | 스택에 포함할 GS2 각 서비스의 리소스를 정의합니다. |
| Outputs | 관리 콘솔에 표시할 출력값을 정의합니다. |
GS2TemplateFormatVersion: "2019-05-01"
Description: GS2-Account initialize template Version 2021-12-03
Globals:
Alias:
AccountNamespaceName: game-0001
KeyNamespaceAccountAuthentication: account-encryption-key-namespace
KeyAccountAuthentication: account-encryption-key
GatewayNamespaceName: gateway-0001
Resources:
GatewayNamespace:
Type: GS2::Gateway::Namespace
Properties:
Name: ${GatewayNamespaceName}
KeyNamespaceAccountAuthentication:
Type: GS2::Key::Namespace
Properties:
Name: ${KeyNamespaceAccountAuthentication}
KeyAccountAuthentication:
Type: GS2::Key::Key
Properties:
NamespaceName: ${KeyNamespaceAccountAuthentication}
Name: ${KeyAccountAuthentication}
DependsOn:
- KeyNamespaceAccountAuthentication
AccountNamespace:
Type: GS2::Account::Namespace
Properties:
Name: ${AccountNamespaceName}
Outputs:
AccountNamespaceName: !GetAttr AccountNamespace.Item.Name
KeyAccountAuthenticationKeyId: !GetAttr KeyAccountAuthentication.Item.KeyId
GatewayNamespaceName: !GetAttr GatewayNamespace.Item.NameGlobals
Alias
지정한 문자열로 Resources 섹션, Outputs 섹션에 있는 문자열을 치환합니다.
좌변의 문자열을 ${...}와 같이 ${}로 감싼 부분을, 우변의 문자열로 치환합니다.
치환 지정 예시: ${AccountNamespaceName}
Globals:
Alias:
AccountNamespaceName: game-0001Resources
생성할 리소스의 정의를 수행합니다. Type 속성, Properties 속성을 가지며, 필요한 경우 DependsOn 속성을 가질 수 있습니다.
Resources:
KeyNamespaceAccountAuthentication: # 리소스 정의 이름
Type: GS2::Key::Namespace # 리소스 지정
Properties:
Name: ${KeyNamespaceAccountAuthentication}
KeyAccountAuthentication: # 리소스 정의 이름
Type: GS2::Key::Key # 리소스 지정
Properties:
NamespaceName: ${KeyNamespaceAccountAuthentication}
Name: ${KeyAccountAuthentication}
DependsOn: # 의존하는 리소스 정의 이름 지정
- KeyNamespaceAccountAuthentication # KeyNamespaceAccountAuthentication 생성에 의존
AccountNamespace: # 리소스 정의 이름
Type: GS2::Account::Namespace # 리소스 지정
Properties:
Name: ${AccountNamespaceName}Type
서비스에 대해 생성을 수행할 리소스의 지정입니다. 각 서비스의 GS2-Deploy/CDK 레퍼런스 페이지에 있는 엔티티 이름을 지정합니다.
예: Type: GS2::Account::Namespace
Properties
리소스를 생성할 때 프로퍼티 값에 부여할 값을 지정합니다.
DependsOn
리소스가 다른 리소스에 이어서 생성되도록, 의존하고 있는 리소스의 이름을 지정합니다.
Outputs
값을 보유하여, 이후 관리 콘솔 등을 통해 값을 확인할 수 있도록 하는 출력값을 정의합니다.
Outputs:
AccountNamespaceName: !GetAttr AccountNamespace.Item.Name
KeyAccountAuthenticationKeyId: !GetAttr KeyAccountAuthentication.Item.KeyId
GatewayNamespaceName: !GetAttr GatewayNamespace.Item.Name함수
GS2-Deploy 템플릿 내에서는 함수를 사용할 수 있습니다.
!GetAttr
!GetAttr 태그를 사용하면 각 리소스의 생성 결과 프로퍼티 값을 가져올 수 있습니다.
AccountNamespace:
Type: GS2::Account::Namespace
Properties:
Name: ${AccountNamespaceName}
Outputs:
AccountNamespaceName: !GetAttr AccountNamespace.Item.Name이 예시에서는 AccountNamespace에서 GS2::Account::Namespace를 지정하고 있으므로, GS2-Account에서 Namespace가 생성됩니다.
그 결과가 AccountNamespace에 저장되며, AccountNamespace.Item에 Namespace 모델이 들어 있습니다.
!GetAttr AccountNamespace.Item.Name으로 네임스페이스 이름을 가져올 수 있습니다.
또한, !GetAttr 태그에는 예약어로 다음이 할당되어 있어, 값을 가져올 수 있습니다.
| 키 값 | 타입 | 설명 |
|---|---|---|
| Gs2::Region | string | 리전 종류 |
| Gs2::OwnerId | string | 오너ID |
!Join
!Join 태그는 뒤에 오는 배열의 문자열을 연결합니다. 구분 기호(딜리미터)를 지정할 수 있습니다.
형식: !Join [ 구분 기호 지정, [연결할 문자열 목록] ]
QueueNamespace:
Type: GS2::JobQueue::Namespace
Properties:
Name: ${QueueNamespaceName}
PushNotification:
GatewayNamespaceId: !Join
- ':'
- - 'grn'
- 'gs2'
- !GetAttr Gs2::Region
- !GetAttr Gs2::OwnerId
- 'gateway'
- ${GatewayNamespaceName}