Skip to content

Commit 39fa6c0

Browse files
committed
deploy whole stack
1 parent 3344f24 commit 39fa6c0

File tree

5 files changed

+80
-53
lines changed

5 files changed

+80
-53
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ repos:
4848
types_or: [sh, shell]
4949
pass_filenames: false
5050

51+
- id: lint-cdk
52+
name: Lint cdk
53+
entry: npm
54+
args: ["run", "--prefix=packages/cdk", "lint"]
55+
language: system
56+
files: ^packages\/cdk
57+
types_or: [ts, tsx, javascript, jsx, json]
58+
pass_filenames: false
59+
5160
- repo: local
5261
hooks:
5362
- id: git-secrets

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ git-secrets-docker-setup:
2929
export LOCAL_WORKSPACE_FOLDER=$(pwd)
3030
docker build -f https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/tags/v4.0.4/dockerfiles/nhsd-git-secrets.dockerfile -t git-secrets .
3131

32-
lint: lint-githubactions lint-githubaction-scripts lint-black lint-flake8
32+
lint: lint-githubactions lint-githubaction-scripts lint-black lint-flake8 lint-node
33+
34+
lint-node:
35+
npm run lint --workspace packages/cdk
3336

3437
lint-githubactions:
3538
actionlint

packages/cdk/constructs/OpenSearchCollection.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class OpenSearchCollection extends Construct {
6262
})
6363

6464
// Vector search collection for document embeddings
65+
// this can not be modified (including tags) so if we modify any properties
66+
// we should ensure the name is changed to ensure a new resource is created
6567
const collection = new CfnCollection(this, "Collection", {
6668
name: props.collectionName,
6769
description: "EPS Assist Vector Store",
@@ -71,6 +73,7 @@ export class OpenSearchCollection extends Construct {
7173
// set static values for commit and version tags to stop it being recreated
7274
Tags.of(collection).add("commit", "static_value")
7375
Tags.of(collection).add("version", "static_value")
76+
7477
// Ensure collection waits for all policies
7578
collection.addDependency(encryptionPolicy)
7679
collection.addDependency(networkPolicy)

packages/cdk/resources/VectorIndex.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,19 @@ export class VectorIndex extends Construct {
3131
},
3232
"AMAZON_BEDROCK_TEXT_CHUNK": {
3333
type: "text",
34-
index: false
34+
index: true
35+
},
36+
"id": {
37+
type: "text",
38+
index: true
39+
},
40+
"x-amz-bedrock-kb-data-source-id": {
41+
type: "text",
42+
index: true
43+
},
44+
"x-amz-bedrock-kb-source-uri": {
45+
type: "text",
46+
index: true
3547
}
3648
}
3749
}

packages/cdk/stacks/EpsAssistMeStack.ts

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -95,43 +95,43 @@ export class EpsAssistMeStack extends Stack {
9595
})
9696

9797
// Create runtime policies with resource dependencies
98-
// const runtimePolicies = new RuntimePolicies(this, "RuntimePolicies", {
99-
// region,
100-
// account,
101-
// slackBotTokenParameterName: secrets.slackBotTokenParameter.parameterName,
102-
// slackSigningSecretParameterName: secrets.slackSigningSecretParameter.parameterName,
103-
// slackBotStateTableArn: tables.slackBotStateTable.table.tableArn,
104-
// slackBotStateTableKmsKeyArn: tables.slackBotStateTable.kmsKey.keyArn,
105-
// knowledgeBaseArn: vectorKB.knowledgeBase.attrKnowledgeBaseArn,
106-
// guardrailArn: vectorKB.guardrail.attrGuardrailArn,
107-
// dataSourceArn: vectorKB.dataSourceArn,
108-
// promptName: bedrockPromptResources.queryReformulationPrompt.promptName
109-
// })
98+
const runtimePolicies = new RuntimePolicies(this, "RuntimePolicies", {
99+
region,
100+
account,
101+
slackBotTokenParameterName: secrets.slackBotTokenParameter.parameterName,
102+
slackSigningSecretParameterName: secrets.slackSigningSecretParameter.parameterName,
103+
slackBotStateTableArn: tables.slackBotStateTable.table.tableArn,
104+
slackBotStateTableKmsKeyArn: tables.slackBotStateTable.kmsKey.keyArn,
105+
knowledgeBaseArn: vectorKB.knowledgeBase.attrKnowledgeBaseArn,
106+
guardrailArn: vectorKB.guardrail.attrGuardrailArn,
107+
dataSourceArn: vectorKB.dataSourceArn,
108+
promptName: bedrockPromptResources.queryReformulationPrompt.promptName
109+
})
110110

111111
// Create Functions construct with actual values from VectorKB
112-
// const functions = new Functions(this, "Functions", {
113-
// stackName: props.stackName,
114-
// version: props.version,
115-
// commitId: props.commitId,
116-
// logRetentionInDays,
117-
// logLevel,
118-
// createIndexManagedPolicy: runtimePolicies.createIndexPolicy,
119-
// slackBotManagedPolicy: runtimePolicies.slackBotPolicy,
120-
// syncKnowledgeBaseManagedPolicy: runtimePolicies.syncKnowledgeBasePolicy,
121-
// slackBotTokenParameter: secrets.slackBotTokenParameter,
122-
// slackSigningSecretParameter: secrets.slackSigningSecretParameter,
123-
// guardrailId: vectorKB.guardrail.attrGuardrailId,
124-
// guardrailVersion: vectorKB.guardrail.attrVersion,
125-
// collectionId: openSearchResources.collection.collection.attrId,
126-
// knowledgeBaseId: vectorKB.knowledgeBase.attrKnowledgeBaseId,
127-
// dataSourceId: vectorKB.dataSource.attrDataSourceId,
128-
// region,
129-
// account,
130-
// slackBotTokenSecret: secrets.slackBotTokenSecret,
131-
// slackBotSigningSecret: secrets.slackBotSigningSecret,
132-
// slackBotStateTable: tables.slackBotStateTable.table,
133-
// promptName: bedrockPromptResources.queryReformulationPrompt.promptName
134-
// })
112+
const functions = new Functions(this, "Functions", {
113+
stackName: props.stackName,
114+
version: props.version,
115+
commitId: props.commitId,
116+
logRetentionInDays,
117+
logLevel,
118+
createIndexManagedPolicy: runtimePolicies.createIndexPolicy,
119+
slackBotManagedPolicy: runtimePolicies.slackBotPolicy,
120+
syncKnowledgeBaseManagedPolicy: runtimePolicies.syncKnowledgeBasePolicy,
121+
slackBotTokenParameter: secrets.slackBotTokenParameter,
122+
slackSigningSecretParameter: secrets.slackSigningSecretParameter,
123+
guardrailId: vectorKB.guardrail.attrGuardrailId,
124+
guardrailVersion: vectorKB.guardrail.attrVersion,
125+
collectionId: openSearchResources.collection.collection.attrId,
126+
knowledgeBaseId: vectorKB.knowledgeBase.attrKnowledgeBaseId,
127+
dataSourceId: vectorKB.dataSource.attrDataSourceId,
128+
region,
129+
account,
130+
slackBotTokenSecret: secrets.slackBotTokenSecret,
131+
slackBotSigningSecret: secrets.slackBotSigningSecret,
132+
slackBotStateTable: tables.slackBotStateTable.table,
133+
promptName: bedrockPromptResources.queryReformulationPrompt.promptName
134+
})
135135

136136
// Create vector index after Functions are created
137137
const vectorIndex = new VectorIndex(this, "VectorIndex", {
@@ -144,26 +144,26 @@ export class EpsAssistMeStack extends Stack {
144144
vectorKB.knowledgeBase.node.addDependency(vectorIndex.cfnIndex)
145145

146146
// Add S3 notification to trigger sync Lambda function
147-
// new S3LambdaNotification(this, "S3LambdaNotification", {
148-
// bucket: storage.kbDocsBucket.bucket,
149-
// lambdaFunction: functions.functions.syncKnowledgeBase.function
150-
// })
147+
new S3LambdaNotification(this, "S3LambdaNotification", {
148+
bucket: storage.kbDocsBucket.bucket,
149+
lambdaFunction: functions.functions.syncKnowledgeBase.function
150+
})
151151

152152
// Create Apis and pass the Lambda function
153-
// const apis = new Apis(this, "Apis", {
154-
// stackName: props.stackName,
155-
// logRetentionInDays,
156-
// enableMutalTls: false,
157-
// functions: {
158-
// slackBot: functions.functions.slackBot
159-
// }
160-
// })
153+
const apis = new Apis(this, "Apis", {
154+
stackName: props.stackName,
155+
logRetentionInDays,
156+
enableMutalTls: false,
157+
functions: {
158+
slackBot: functions.functions.slackBot
159+
}
160+
})
161161

162162
// Output: SlackBot Endpoint
163-
// new CfnOutput(this, "SlackBotEventsEndpoint", {
164-
// value: `https://${apis.apis["api"].api.domainName?.domainName}/slack/events`,
165-
// description: "Slack Events API endpoint for @mentions and direct messages"
166-
// })
163+
new CfnOutput(this, "SlackBotEventsEndpoint", {
164+
value: `https://${apis.apis["api"].api.domainName?.domainName}/slack/events`,
165+
description: "Slack Events API endpoint for @mentions and direct messages"
166+
})
167167

168168
// Output: Bedrock Prompt ARN
169169
new CfnOutput(this, "QueryReformulationPromptArn", {

0 commit comments

Comments
 (0)