Skip to content

Commit ec75fd8

Browse files
authored
fix: prevent unintended override of construct and stack props (#1006)
1 parent 745fe2f commit ec75fd8

14 files changed

+102
-102
lines changed

packages/cdk/lib/agent-stack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Agent as AgentType } from 'generative-ai-use-cases';
55
import { ProcessedStackInput } from './stack-input';
66

77
export interface AgentStackProps extends StackProps {
8-
params: ProcessedStackInput;
8+
readonly params: ProcessedStackInput;
99
}
1010

1111
export class AgentStack extends Stack {

packages/cdk/lib/cloud-front-waf-stack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CommonWebAcl } from './construct/common-web-acl';
1010
import { ProcessedStackInput } from './stack-input';
1111

1212
interface CloudFrontWafStackProps extends StackProps {
13-
params: ProcessedStackInput;
13+
readonly params: ProcessedStackInput;
1414
}
1515

1616
export class CloudFrontWafStack extends Stack {

packages/cdk/lib/construct/agent.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import { Agent as AgentType } from 'generative-ai-use-cases';
2020

2121
interface AgentProps {
2222
// Context Params
23-
searchAgentEnabled: boolean;
24-
searchApiKey?: string | null;
23+
readonly searchAgentEnabled: boolean;
24+
readonly searchApiKey?: string | null;
2525
}
2626

2727
export class Agent extends Construct {

packages/cdk/lib/construct/api.ts

+18-18
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ import {
3030

3131
export interface BackendApiProps {
3232
// Context Params
33-
modelRegion: string;
34-
modelIds: ModelConfiguration[];
35-
imageGenerationModelIds: ModelConfiguration[];
36-
videoGenerationModelIds: ModelConfiguration[];
37-
videoBucketRegionMap: Record<string, string>;
38-
endpointNames: string[];
39-
queryDecompositionEnabled: boolean;
40-
rerankingModelId?: string | null;
41-
customAgents: Agent[];
42-
crossAccountBedrockRoleArn?: string | null;
33+
readonly modelRegion: string;
34+
readonly modelIds: ModelConfiguration[];
35+
readonly imageGenerationModelIds: ModelConfiguration[];
36+
readonly videoGenerationModelIds: ModelConfiguration[];
37+
readonly videoBucketRegionMap: Record<string, string>;
38+
readonly endpointNames: string[];
39+
readonly queryDecompositionEnabled: boolean;
40+
readonly rerankingModelId?: string | null;
41+
readonly customAgents: Agent[];
42+
readonly crossAccountBedrockRoleArn?: string | null;
4343

4444
// Resource
45-
userPool: UserPool;
46-
idPool: IdentityPool;
47-
userPoolClient: UserPoolClient;
48-
table: Table;
49-
knowledgeBaseId?: string;
50-
agents?: Agent[];
51-
guardrailIdentify?: string;
52-
guardrailVersion?: string;
45+
readonly userPool: UserPool;
46+
readonly idPool: IdentityPool;
47+
readonly userPoolClient: UserPoolClient;
48+
readonly table: Table;
49+
readonly knowledgeBaseId?: string;
50+
readonly agents?: Agent[];
51+
readonly guardrailIdentify?: string;
52+
readonly guardrailVersion?: string;
5353
}
5454

5555
export class Api extends Construct {

packages/cdk/lib/construct/auth.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import { Runtime } from 'aws-cdk-lib/aws-lambda';
1414
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
1515

1616
export interface AuthProps {
17-
selfSignUpEnabled: boolean;
18-
allowedIpV4AddressRanges?: string[] | null;
19-
allowedIpV6AddressRanges?: string[] | null;
20-
allowedSignUpEmailDomains?: string[] | null;
21-
samlAuthEnabled: boolean;
17+
readonly selfSignUpEnabled: boolean;
18+
readonly allowedIpV4AddressRanges?: string[] | null;
19+
readonly allowedIpV6AddressRanges?: string[] | null;
20+
readonly allowedSignUpEmailDomains?: string[] | null;
21+
readonly samlAuthEnabled: boolean;
2222
}
2323

2424
export class Auth extends Construct {

packages/cdk/lib/construct/common-web-acl.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { CfnIPSet, CfnWebACL, CfnWebACLProps } from 'aws-cdk-lib/aws-wafv2';
33
import { Construct } from 'constructs';
44

55
export interface CommonWebAclProps {
6-
scope: 'REGIONAL' | 'CLOUDFRONT';
7-
allowedIpV4AddressRanges?: string[] | null;
8-
allowedIpV6AddressRanges?: string[] | null;
9-
allowedCountryCodes?: string[] | null;
6+
readonly scope: 'REGIONAL' | 'CLOUDFRONT';
7+
readonly allowedIpV4AddressRanges?: string[] | null;
8+
readonly allowedIpV6AddressRanges?: string[] | null;
9+
readonly allowedCountryCodes?: string[] | null;
1010
}
1111

1212
export class CommonWebAcl extends Construct {

packages/cdk/lib/construct/rag-knowledge-base.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import { Runtime } from 'aws-cdk-lib/aws-lambda';
1313

1414
export interface RagKnowledgeBaseProps {
1515
// Context Params
16-
modelRegion: string;
16+
readonly modelRegion: string;
1717

1818
// Resource
19-
knowledgeBaseId: string;
20-
userPool: UserPool;
21-
api: RestApi;
19+
readonly knowledgeBaseId: string;
20+
readonly userPool: UserPool;
21+
readonly api: RestApi;
2222
}
2323

2424
export class RagKnowledgeBase extends Construct {

packages/cdk/lib/construct/rag.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ const KENDRA_STATE_CFN_PARAMETER_NAME = 'kendraState';
2323

2424
export interface RagProps {
2525
// Context Params
26-
envSuffix: string;
27-
kendraIndexLanguage: string;
28-
kendraIndexArnInCdkContext?: string | null;
29-
kendraDataSourceBucketName?: string | null;
30-
kendraIndexScheduleEnabled: boolean;
31-
kendraIndexScheduleCreateCron?: IndexScheduleCron | null;
32-
kendraIndexScheduleDeleteCron?: IndexScheduleCron | null;
26+
readonly envSuffix: string;
27+
readonly kendraIndexLanguage: string;
28+
readonly kendraIndexArnInCdkContext?: string | null;
29+
readonly kendraDataSourceBucketName?: string | null;
30+
readonly kendraIndexScheduleEnabled: boolean;
31+
readonly kendraIndexScheduleCreateCron?: IndexScheduleCron | null;
32+
readonly kendraIndexScheduleDeleteCron?: IndexScheduleCron | null;
3333

3434
// Resource
35-
userPool: UserPool;
36-
api: RestApi;
35+
readonly userPool: UserPool;
36+
readonly api: RestApi;
3737
}
3838

3939
export interface IndexScheduleCron {
40-
minute: string;
41-
hour: string;
42-
month: string;
43-
weekDay: string;
40+
readonly minute: string;
41+
readonly hour: string;
42+
readonly month: string;
43+
readonly weekDay: string;
4444
}
4545

4646
class KendraIndexWithCfnParameter extends kendra.CfnIndex {

packages/cdk/lib/construct/transcribe.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import {
1919
import { Construct } from 'constructs';
2020

2121
export interface TranscribeProps {
22-
userPool: UserPool;
23-
idPool: IdentityPool;
24-
api: RestApi;
22+
readonly userPool: UserPool;
23+
readonly idPool: IdentityPool;
24+
readonly api: RestApi;
2525
}
2626

2727
export class Transcribe extends Construct {

packages/cdk/lib/construct/use-case-builder.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { UserPool } from 'aws-cdk-lib/aws-cognito';
1515
import * as ddb from 'aws-cdk-lib/aws-dynamodb';
1616

1717
export interface UseCaseBuilderProps {
18-
userPool: UserPool;
19-
api: RestApi;
18+
readonly userPool: UserPool;
19+
readonly api: RestApi;
2020
}
2121
export class UseCaseBuilder extends Construct {
2222
constructor(scope: Construct, id: string, props: UseCaseBuilderProps) {

packages/cdk/lib/construct/web.ts

+29-29
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,35 @@ import {
1818
import { ComputeType } from 'aws-cdk-lib/aws-codebuild';
1919

2020
export interface WebProps {
21-
apiEndpointUrl: string;
22-
userPoolId: string;
23-
userPoolClientId: string;
24-
idPoolId: string;
25-
predictStreamFunctionArn: string;
26-
ragEnabled: boolean;
27-
ragKnowledgeBaseEnabled: boolean;
28-
agentEnabled: boolean;
29-
flows?: Flow[];
30-
flowStreamFunctionArn: string;
31-
optimizePromptFunctionArn: string;
32-
selfSignUpEnabled: boolean;
33-
webAclId?: string;
34-
modelRegion: string;
35-
modelIds: ModelConfiguration[];
36-
imageGenerationModelIds: ModelConfiguration[];
37-
videoGenerationModelIds: ModelConfiguration[];
38-
endpointNames: string[];
39-
samlAuthEnabled: boolean;
40-
samlCognitoDomainName?: string | null;
41-
samlCognitoFederatedIdentityProviderName?: string | null;
42-
agentNames: string[];
43-
inlineAgents: boolean;
44-
cert?: ICertificate;
45-
hostName?: string | null;
46-
domainName?: string | null;
47-
hostedZoneId?: string | null;
48-
useCaseBuilderEnabled: boolean;
49-
hiddenUseCases: HiddenUseCases;
21+
readonly apiEndpointUrl: string;
22+
readonly userPoolId: string;
23+
readonly userPoolClientId: string;
24+
readonly idPoolId: string;
25+
readonly predictStreamFunctionArn: string;
26+
readonly ragEnabled: boolean;
27+
readonly ragKnowledgeBaseEnabled: boolean;
28+
readonly agentEnabled: boolean;
29+
readonly flows?: Flow[];
30+
readonly flowStreamFunctionArn: string;
31+
readonly optimizePromptFunctionArn: string;
32+
readonly selfSignUpEnabled: boolean;
33+
readonly webAclId?: string;
34+
readonly modelRegion: string;
35+
readonly modelIds: ModelConfiguration[];
36+
readonly imageGenerationModelIds: ModelConfiguration[];
37+
readonly videoGenerationModelIds: ModelConfiguration[];
38+
readonly endpointNames: string[];
39+
readonly samlAuthEnabled: boolean;
40+
readonly samlCognitoDomainName?: string | null;
41+
readonly samlCognitoFederatedIdentityProviderName?: string | null;
42+
readonly agentNames: string[];
43+
readonly inlineAgents: boolean;
44+
readonly cert?: ICertificate;
45+
readonly hostName?: string | null;
46+
readonly domainName?: string | null;
47+
readonly hostedZoneId?: string | null;
48+
readonly useCaseBuilderEnabled: boolean;
49+
readonly hiddenUseCases: HiddenUseCases;
5050
}
5151

5252
export class Web extends Construct {

packages/cdk/lib/dashboard-stack.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { ProcessedStackInput } from './stack-input';
77
import { ModelConfiguration } from 'generative-ai-use-cases';
88

99
export interface DashboardStackProps extends StackProps {
10-
params: ProcessedStackInput;
11-
userPool: cognito.UserPool;
12-
userPoolClient: cognito.UserPoolClient;
13-
appRegion: string;
10+
readonly params: ProcessedStackInput;
11+
readonly userPool: cognito.UserPool;
12+
readonly userPoolClient: cognito.UserPoolClient;
13+
readonly appRegion: string;
1414
}
1515

1616
export class DashboardStack extends Stack {

packages/cdk/lib/generative-ai-use-cases-stack.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ import { UseCaseBuilder } from './construct/use-case-builder';
1818
import { ProcessedStackInput } from './stack-input';
1919

2020
export interface GenerativeAiUseCasesStackProps extends StackProps {
21-
params: ProcessedStackInput;
21+
readonly params: ProcessedStackInput;
2222
// RAG Knowledge Base
23-
knowledgeBaseId?: string;
24-
knowledgeBaseDataSourceBucketName?: string;
23+
readonly knowledgeBaseId?: string;
24+
readonly knowledgeBaseDataSourceBucketName?: string;
2525
// Agent
26-
agents?: Agent[];
26+
readonly agents?: Agent[];
2727
// Video Generation
28-
videoBucketRegionMap: Record<string, string>;
28+
readonly videoBucketRegionMap: Record<string, string>;
2929
// Guardrail
30-
guardrailIdentifier?: string;
31-
guardrailVersion?: string;
30+
readonly guardrailIdentifier?: string;
31+
readonly guardrailVersion?: string;
3232
// WAF
33-
webAclId?: string;
33+
readonly webAclId?: string;
3434
// Custom Domain
35-
cert?: ICertificate;
35+
readonly cert?: ICertificate;
3636
}
3737

3838
export class GenerativeAiUseCasesStack extends Stack {

packages/cdk/lib/rag-knowledge-base-stack.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ Financial Activity 6,291 9,718`;
7676
const EMBEDDING_MODELS = Object.keys(MODEL_VECTOR_MAPPING);
7777

7878
interface OpenSearchServerlessIndexProps {
79-
collectionId: string;
80-
vectorIndexName: string;
81-
vectorField: string;
82-
metadataField: string;
83-
textField: string;
84-
vectorDimension: string;
85-
ragKnowledgeBaseBinaryVector: boolean;
79+
readonly collectionId: string;
80+
readonly vectorIndexName: string;
81+
readonly vectorField: string;
82+
readonly metadataField: string;
83+
readonly textField: string;
84+
readonly vectorDimension: string;
85+
readonly ragKnowledgeBaseBinaryVector: boolean;
8686
}
8787

8888
class OpenSearchServerlessIndex extends Construct {

0 commit comments

Comments
 (0)