Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/en/DEPLOY_OPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1808,14 +1808,15 @@ EventBridge rules are used for scheduling, and Step Functions for process contro
### How to Set Tags

GenU supports tags for cost management and other purposes. The key name of the tag is automatically set to `GenU` `. Here are examples of how to set them:
GenU supports tags for cost management and other purposes. By default, the key name of the tag is set to `GenU`, but you can use a custom tag key by specifying `tagKey`. Here are examples of how to set them:

Setting in `cdk.json`:

```json
// cdk.json
...
"context": {
"tagKey": "MyProject", // Custom tag key (optional, default is "GenU")
"tagValue": "dev",
...
```
Expand All @@ -1824,6 +1825,7 @@ Setting in `parameter.ts`:

```typescript
...
tagKey: "MyProject", // Custom tag key (optional, default is "GenU")
tagValue: "dev",
...
```
Expand Down
4 changes: 3 additions & 1 deletion docs/ja/DEPLOY_OPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ Kendraのインデックスが削除されても、RAG機能はオンのまま
### タグを設定する方法

GenU ではコスト管理等に使うためのタグをサポートしています。タグのキー名には、自動で `GenU` `が設定されます
GenU ではコスト管理等に使うためのタグをサポートしています。デフォルトでは、タグのキー名に `GenU` が設定されますが、`tagKey` を指定することでカスタムのタグキーを使用できます
以下に設定例を示します。

`cdk.json` での設定方法
Expand All @@ -1824,6 +1824,7 @@ GenU ではコスト管理等に使うためのタグをサポートしていま
// cdk.json
...
"context": {
"tagKey": "MyProject", // カスタムのタグキー(省略可能、デフォルトは "GenU")
"tagValue": "dev",
...
```
Expand All @@ -1832,6 +1833,7 @@ GenU ではコスト管理等に使うためのタグをサポートしていま

```typescript
...
tagKey: "MyProject", // カスタムのタグキー(省略可能、デフォルトは "GenU")
tagValue: "dev",
...
```
Expand Down
4 changes: 3 additions & 1 deletion docs/ko/DEPLOY_OPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1817,14 +1817,15 @@ Kendra 인덱스가 삭제되어도 RAG 기능은 계속 켜져 있습니다.
### 태그 설정 방법

GenU는 비용 관리 및 기타 목적을 위한 태그를 지원합니다. 태그의 키 이름은 자동으로 `GenU`설정됩니다. 설정 방법의 예시는 다음과 같습니다:
GenU는 비용 관리 및 기타 목적을 위한 태그를 지원합니다. 기본적으로 태그의 키 이름은 `GenU`설정되지만, `tagKey`를 지정하여 사용자 정의 태그 키를 사용할 수 있습니다. 설정 방법의 예시는 다음과 같습니다:

`cdk.json`에서 설정:

```json
// cdk.json
...
"context": {
"tagKey": "MyProject", // 사용자 정의 태그 키 (선택사항, 기본값은 "GenU")
"tagValue": "dev",
...
```
Expand All @@ -1833,6 +1834,7 @@ GenU는 비용 관리 및 기타 목적을 위한 태그를 지원합니다. 태

```typescript
...
tagKey: "MyProject", // 사용자 정의 태그 키 (선택사항, 기본값은 "GenU")
tagValue: "dev",
...
```
Expand Down
3 changes: 2 additions & 1 deletion packages/cdk/bin/generative-ai-use-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { TAG_KEY } from '../consts';
const app = new cdk.App();
const params = getParams(app);
if (params.tagValue) {
cdk.Tags.of(app).add(TAG_KEY, params.tagValue, {
const tagKey = params.tagKey || TAG_KEY;
cdk.Tags.of(app).add(tagKey, params.tagValue, {
// Exclude OpenSearchServerless Collection from tagging
excludeResourceTypes: ['AWS::OpenSearchServerless::Collection'],
});
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"context": {
"env": "",
"tagKey": null,
"tagValue": null,
"ragEnabled": false,
"kendraIndexArn": null,
Expand Down
3 changes: 2 additions & 1 deletion packages/cdk/lib/rag-knowledge-base-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class RagKnowledgeBaseStack extends Stack {
ragKnowledgeBaseAdvancedParsingModelId,
ragKnowledgeBaseBinaryVector,
crossAccountBedrockRoleArn,
tagKey,
tagValue,
} = props.params;

Expand Down Expand Up @@ -312,7 +313,7 @@ export class RagKnowledgeBaseStack extends Stack {
resourceType: 'Custom::ApplyTags',
properties: {
tag: {
key: TAG_KEY,
key: tagKey || TAG_KEY,
value: tagValue || '', // Pass empty string when tagValue is unset
},
collectionId: collection.ref,
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/lib/stack-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const baseStackInputSchema = z.object({
// Dashboard
dashboard: z.boolean().default(false),
// Tag
tagKey: z.string().nullish(),
tagValue: z.string().nullish(),
// Closed network
closedNetworkMode: z.boolean().default(false),
Expand Down
48 changes: 48 additions & 0 deletions packages/cdk/test/generative-ai-use-cases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ describe('GenerativeAiUseCases', () => {
guardrailEnabled: true,
crossAccountBedrockRoleArn: '',
useCaseBuilderEnabled: true,
tagKey: null,
tagValue: null,
};

test('matches the snapshot', () => {
Expand Down Expand Up @@ -160,4 +162,50 @@ describe('GenerativeAiUseCases', () => {
expect(generativeAiUseCasesTemplate.toJSON()).toMatchSnapshot();
expect(dashboardTemplate.toJSON()).toMatchSnapshot();
});

test('tagKey functionality', () => {
// Test with custom tagKey
const appWithCustomTag = new cdk.App();
const paramsWithCustomTag = processedStackInputSchema.parse({
...stackInput,
tagKey: 'CustomTag',
tagValue: 'custom-value',
});

const stacksWithCustomTag = createStacks(
appWithCustomTag,
paramsWithCustomTag
);

// Test without tagKey (should use default)
const appWithoutTagKey = new cdk.App();
const paramsWithoutTagKey = processedStackInputSchema.parse({
...stackInput,
tagKey: null,
tagValue: 'default-value',
});

const stacksWithoutTagKey = createStacks(
appWithoutTagKey,
paramsWithoutTagKey
);

// Assert that both scenarios create stacks successfully
expect(stacksWithCustomTag.generativeAiUseCasesStack).toBeDefined();
expect(stacksWithoutTagKey.generativeAiUseCasesStack).toBeDefined();

// Test that RagKnowledgeBaseStack is created properly with custom tagKey
if (stacksWithCustomTag.ragKnowledgeBaseStack) {
const customTagTemplate = Template.fromStack(
stacksWithCustomTag.ragKnowledgeBaseStack
);
// Check that custom resource uses the custom tag key
customTagTemplate.hasResourceProperties('Custom::ApplyTags', {
tag: {
key: 'CustomTag',
value: 'custom-value',
},
});
}
});
});