GS2-Log GS2-Deploy/CDK リファレンス
GS2-Deployのスタックを作成する際に使用するテンプレートのフォーマットと、CDKによる各種言語のテンプレート出力の実装例
エンティティ
Deploy処理で操作する対象リソース
Namespace
ネームスペース
ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 の各サービスはネームスペース単位で管理されます。ネームスペースが異なれば、同じサービスでも完全に独立したデータ空間として扱われます。
そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。
| 型 | 有効化条件 | 必須 | デフォルト | 値の制限 | 説明 | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| namespaceId | string | ✓ | ~ 1024文字 | ネームスペース GRN | ||||||||||
| name | string | ✓ | ~ 128文字 | ネームスペース名 | ||||||||||
| description | string | ~ 1024文字 | 説明文 | |||||||||||
| type | 文字列列挙型 enum { “gs2”, “bigquery”, “firehose” } | ✓ | “gs2” | ログの書き出し方法
| ||||||||||
| gcpCredentialJson | string | {type} == “bigquery” | ✓* | ~ 5120文字 | GCPのクレデンシャル ※ type が “bigquery” であれば 必須 | |||||||||
| bigQueryDatasetName | string | {type} == “bigquery” | ✓* | ~ 1024文字 | BigQueryのデータセット名 ※ type が “bigquery” であれば 必須 | |||||||||
| logExpireDays | int | {type} in [“gs2”, “bigquery”] | ✓* | 0 ~ 3650 | ログの保存期間(日) ※ type が “gs2”,“bigquery"であれば 必須 | |||||||||
| awsRegion | string | {type} == “firehose” | ✓* | ~ 256文字 | AWSのリージョン ※ type が “firehose” であれば 必須 | |||||||||
| awsAccessKeyId | string | {type} == “firehose” | ✓* | ~ 256文字 | AWSのアクセスキーID ※ type が “firehose” であれば 必須 | |||||||||
| awsSecretAccessKey | string | {type} == “firehose” | ✓* | ~ 256文字 | AWSのシークレットアクセスキー ※ type が “firehose” であれば 必須 | |||||||||
| firehoseStreamName | string | {type} == “firehose” | ✓* | ~ 256文字 | Kinesis Firehose のストリーム名 ※ type が “firehose” であれば 必須 | |||||||||
| firehoseCompressData | 文字列列挙型 enum { “none”, “gzip” } | {type} == “firehose” | ✓* | “none” | Kinesis Firehose に出力するデータを圧縮するか
※ type が “firehose” であれば 必須 | |||||||||
| status | string | “ACTIVE” | ~ 128文字 | ステータス | ||||||||||
| createdAt | long | ✓ | 現在時刻 | 作成日時 UNIX 時間・ミリ秒 サーバー側で自動的に設定 | ||||||||||
| updatedAt | long | ✓ | 現在時刻 | 最終更新日時 UNIX 時間・ミリ秒 サーバー側で自動的に設定 | ||||||||||
| revision | long | 0 | 0 ~ 9223372036854775805 | リビジョン |
GetAttr
!GetAttrタグで取得可能なリソースの生成結果
| 型 | 説明 | |
|---|---|---|
| Item | Namespace | 作成したネームスペース |
実装例
Type: GS2::Log::Namespace
Properties:
Name: namespace-0001
Description: null
Type: gs2
GcpCredentialJson: {"project_id": "gs2-dev"}
BigQueryDatasetName: dataset_0001
LogExpireDays: 3
AwsRegion: awsRegion
AwsAccessKeyId: awsAccessKeyId
AwsSecretAccessKey: awsSecretAccessKey
FirehoseStreamName: firehoseStreamName
FirehoseCompressData: nullimport (
"github.com/gs2io/gs2-golang-cdk/core"
"github.com/gs2io/gs2-golang-cdk/log"
"github.com/openlyinc/pointy"
)
SampleStack := core.NewStack()
log.NewNamespace(
&SampleStack,
"namespace-0001",
log.NamespaceOptions{
Type: log.NamespaceTypeGs2,
GcpCredentialJson: pointy.String("{\"project_id\": \"gs2-dev\"}"),
BigQueryDatasetName: pointy.String("dataset_0001"),
LogExpireDays: pointy.Int32(3),
AwsRegion: pointy.String("awsRegion"),
AwsAccessKeyId: pointy.String("awsAccessKeyId"),
AwsSecretAccessKey: pointy.String("awsSecretAccessKey"),
FirehoseStreamName: pointy.String("firehoseStreamName"),
},
)
println(SampleStack.Yaml()) // Generate Template
class SampleStack extends \Gs2Cdk\Core\Model\Stack
{
function __construct() {
parent::__construct();
new \Gs2Cdk\Log\Model\Namespace_(
stack: $this,
name: "namespace-0001",
options: new \Gs2Cdk\Log\Model\Options\NamespaceOptions(
type: Gs2Cdk\Log\Model\Enums\NamespaceType::GS2,
gcpCredentialJson: "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName: "dataset_0001",
logExpireDays: 3,
awsRegion: "awsRegion",
awsAccessKeyId: "awsAccessKeyId",
awsSecretAccessKey: "awsSecretAccessKey",
firehoseStreamName: "firehoseStreamName"
)
);
}
}
print((new SampleStack())->yaml()); // Generate Template
class SampleStack extends io.gs2.cdk.core.model.Stack
{
public SampleStack() {
super();
new io.gs2.cdk.log.model.Namespace(
this,
"namespace-0001",
new io.gs2.cdk.log.model.options.NamespaceOptions()
.withType(io.gs2.cdk.log.model.enums.NamespaceType.GS2)
.withGcpCredentialJson("{\"project_id\": \"gs2-dev\"}")
.withBigQueryDatasetName("dataset_0001")
.withLogExpireDays(3)
.withAwsRegion("awsRegion")
.withAwsAccessKeyId("awsAccessKeyId")
.withAwsSecretAccessKey("awsSecretAccessKey")
.withFirehoseStreamName("firehoseStreamName")
);
}
}
System.out.println(new SampleStack().yaml()); // Generate Templatepublic class SampleStack : Gs2Cdk.Core.Model.Stack
{
public SampleStack() {
new Gs2Cdk.Gs2Log.Model.Namespace(
stack: this,
name: "namespace-0001",
options: new Gs2Cdk.Gs2Log.Model.Options.NamespaceOptions
{
type = Gs2Cdk.Gs2Log.Model.Enums.NamespaceType.Gs2,
gcpCredentialJson = "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName = "dataset_0001",
logExpireDays = 3,
awsRegion = "awsRegion",
awsAccessKeyId = "awsAccessKeyId",
awsSecretAccessKey = "awsSecretAccessKey",
firehoseStreamName = "firehoseStreamName"
}
);
}
}
Debug.Log(new SampleStack().Yaml()); // Generate Templateimport core from "@/gs2cdk/core";
import log from "@/gs2cdk/log";
class SampleStack extends core.Stack
{
public constructor() {
super();
new log.model.Namespace(
this,
"namespace-0001",
{
type: log.model.NamespaceType.GS2,
gcpCredentialJson: "{\"project_id\": \"gs2-dev\"}",
bigQueryDatasetName: "dataset_0001",
logExpireDays: 3,
awsRegion: "awsRegion",
awsAccessKeyId: "awsAccessKeyId",
awsSecretAccessKey: "awsSecretAccessKey",
firehoseStreamName: "firehoseStreamName"
}
);
}
}
console.log(new SampleStack().yaml()); // Generate Template
from gs2_cdk import Stack, core, log
class SampleStack(Stack):
def __init__(self):
super().__init__()
log.Namespace(
stack=self,
name='namespace-0001',
options=log.NamespaceOptions(
type=log.NamespaceType.GS2,
gcp_credential_json='{"project_id": "gs2-dev"}',
big_query_dataset_name='dataset_0001',
log_expire_days=3,
aws_region='awsRegion',
aws_access_key_id='awsAccessKeyId',
aws_secret_access_key='awsSecretAccessKey',
firehose_stream_name='firehoseStreamName',
),
)
print(SampleStack().yaml()) # Generate Template