Skip to content

Commit 1492597

Browse files
authored
New: [AEA-5543] - Integrate AWS Bedrock Sample Slackbot into EPS Assist Me (#11)
## Summary 🎫 [AEA-5543](https://nhsd-jira.digital.nhs.uk/browse/AEA-5543) Amazon Bedrock Knowledge Base Slack ChatBot :sparkles: New Feature ### Details This PR introduces the initial implementation of a Slack chatbot that leverages Amazon Bedrock’s Knowledge Base to answer queries, using AWS-provided sample code as a foundation.
1 parent 0055531 commit 1492597

39 files changed

+8018
-11599
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
FROM mcr.microsoft.com/devcontainers/base:ubuntu
22

33
# Install system dependencies
4-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5-
&& apt-get -y install --no-install-recommends \
6-
curl git build-essential libssl-dev zlib1g-dev \
7-
libbz2-dev libreadline-dev libsqlite3-dev wget llvm \
8-
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
9-
liblzma-dev python3-pip libffi-dev libyaml-dev
4+
RUN apt-get update \
5+
&& export DEBIAN_FRONTEND=noninteractive \
6+
&& apt-get -y dist-upgrade \
7+
&& apt-get -y install --no-install-recommends htop vim curl git build-essential \
8+
libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev libbz2-dev \
9+
zlib1g-dev unixodbc unixodbc-dev libsecret-1-0 libsecret-1-dev libsqlite3-dev \
10+
jq apt-transport-https ca-certificates gnupg-agent \
11+
software-properties-common bash-completion python3-pip make libbz2-dev \
12+
libreadline-dev libsqlite3-dev wget llvm libncurses5-dev libncursesw5-dev \
13+
xz-utils tk-dev liblzma-dev netcat-openbsd libyaml-dev
14+
15+
# Install aws stuff
16+
RUN wget -O /tmp/awscliv2.zip "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" && \
17+
unzip /tmp/awscliv2.zip -d /tmp/aws-cli && \
18+
/tmp/aws-cli/aws/install && \
19+
rm tmp/awscliv2.zip && \
20+
rm -rf /tmp/aws-cli
1021

1122
# Set user to vscode
1223
USER vscode
@@ -41,4 +52,5 @@ ADD .tool-versions /home/vscode/.tool-versions
4152
RUN asdf install; \
4253
asdf reshim python; \
4354
asdf reshim poetry; \
55+
asdf reshim nodejs; \
4456
asdf direnv setup --shell bash --version 2.32.2;

.gitallowed

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ sha256:[a-f0-9]{64}
2323
.*=\s*"[><=!~^,0-9\s\.]+"
2424
app = App\(token=bot_token\)
2525
token=bot_token
26+
token: slackBotToken
27+
token: props\.slackBotToken
28+
secretValue: JSON\.stringify\(\{token: props\.slackBotToken\}\)

.github/workflows/cdk_package_code.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: cdk package code
33
on:
44
workflow_call:
55
inputs:
6+
STACK_NAME:
7+
required: true
8+
type: string
69
VERSION_NUMBER:
710
required: true
811
type: string
@@ -56,6 +59,11 @@ jobs:
5659
run: |
5760
make install
5861
62+
- name: Build Python Lambda Functions
63+
run: |
64+
pip3 install -r packages/slackBotFunction/requirements.txt -t packages/slackBotFunction
65+
pip3 install -r packages/createIndexFunction/requirements.txt -t packages/createIndexFunction
66+
5967
- name: 'Tar files'
6068
run: |
6169
tar -rf artifact.tar \

.github/workflows/cdk_release_code.yml

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ on:
1818
CDK_APP_NAME:
1919
required: true
2020
type: string
21+
DEPLOY_CODE:
22+
type: boolean
23+
default: false
2124
LOG_RETENTION_IN_DAYS:
2225
required: true
2326
type: string
@@ -74,7 +77,7 @@ jobs:
7477
with:
7578
name: build_artifact
7679

77-
- name: extract build_artifact
80+
- name: Extract build_artifact
7881
run: |
7982
mkdir -p .build
8083
tar -xf artifact.tar -C .build
@@ -106,6 +109,7 @@ jobs:
106109
run: |
107110
./.github/scripts/fix_cdk_json.sh
108111
env:
112+
ACCOUNT_ID: "${{ env.ACCOUNT_ID }}"
109113
STACK_NAME: "${{ inputs.STACK_NAME }}"
110114
VERSION_NUMBER: "${{ inputs.VERSION_NUMBER }}"
111115
COMMIT_ID: "${{ inputs.COMMIT_ID }}"
@@ -117,35 +121,29 @@ jobs:
117121
- name: Show diff
118122
run: |
119123
docker run \
120-
-v "$(pwd)/.build":/home/cdkuser/workspace/ \
121-
-e AWS_ACCESS_KEY_ID=${{ steps.connect-aws.outputs.aws-access-key-id }} \
122-
-e AWS_SECRET_ACCESS_KEY=${{ steps.connect-aws.outputs.aws-secret-access-key }} \
123-
-e AWS_SESSION_TOKEN=${{ steps.connect-aws.outputs.aws-session-token }} \
124-
-e AWS_REGION="eu-west-2" \
125-
-e stack_name="${{ inputs.STACK_NAME }}" \
126-
-e VERSION_NUMBER="${{ inputs.VERSION_NUMBER}}" \
127-
-e COMMIT_ID="${{ inputs.COMMIT_ID}}" \
128-
-e SHOW_DIFF="true" \
129-
-e DEPLOY_CODE="false" \
130-
-e CDK_APP_PATH="packages/cdk/bin/EpsAssistMeApp.ts" \
131-
cdk-utils-build-repo:latest
132-
shell: bash
124+
-v "$(pwd)/.build":/home/cdkuser/workspace/ \
125+
-e AWS_ACCESS_KEY_ID=${{ steps.connect-aws.outputs.aws-access-key-id }} \
126+
-e AWS_SECRET_ACCESS_KEY=${{ steps.connect-aws.outputs.aws-secret-access-key }} \
127+
-e AWS_SESSION_TOKEN=${{ steps.connect-aws.outputs.aws-session-token }} \
128+
-e AWS_REGION="eu-west-2" \
129+
-e SHOW_DIFF="true" \
130+
-e DEPLOY_CODE="false" \
131+
-e CDK_APP_PATH="packages/cdk/bin/EpsAssistMeApp.ts" \
132+
cdk-utils-build-repo:latest
133133
134134
- name: Deploy code
135+
if: ${{ inputs.DEPLOY_CODE == true }}
135136
run: |
136137
docker run \
137-
-v "$(pwd)/.build":/home/cdkuser/workspace/ \
138-
-e AWS_ACCESS_KEY_ID=${{ steps.connect-aws.outputs.aws-access-key-id }} \
139-
-e AWS_SECRET_ACCESS_KEY=${{ steps.connect-aws.outputs.aws-secret-access-key }} \
140-
-e AWS_SESSION_TOKEN=${{ steps.connect-aws.outputs.aws-session-token }} \
141-
-e AWS_REGION="eu-west-2" \
142-
-e stack_name="${{ inputs.STACK_NAME }}" \
143-
-e VERSION_NUMBER="${{ inputs.VERSION_NUMBER}}" \
144-
-e COMMIT_ID="${{ inputs.COMMIT_ID}}" \
145-
-e SHOW_DIFF="false" \
146-
-e DEPLOY_CODE="true" \
147-
-e CDK_APP_PATH="packages/cdk/bin/EpsAssistMeApp.ts" \
148-
cdk-utils-build-repo:latest
138+
-v "$(pwd)/.build":/home/cdkuser/workspace/ \
139+
-e AWS_ACCESS_KEY_ID=${{ steps.connect-aws.outputs.aws-access-key-id }} \
140+
-e AWS_SECRET_ACCESS_KEY=${{ steps.connect-aws.outputs.aws-secret-access-key }} \
141+
-e AWS_SESSION_TOKEN=${{ steps.connect-aws.outputs.aws-session-token }} \
142+
-e AWS_REGION="eu-west-2" \
143+
-e SHOW_DIFF="false" \
144+
-e DEPLOY_CODE="true" \
145+
-e CDK_APP_PATH="packages/cdk/bin/EpsAssistMeApp.ts" \
146+
cdk-utils-build-repo:latest
149147
shell: bash
150148

151149
- name: mark_released_in_jira
@@ -162,13 +160,6 @@ jobs:
162160
ref: gh-pages
163161
path: gh-pages
164162

165-
- name: Checkout gh-pages
166-
if: ${{ !startsWith(inputs.STACK_NAME, 'lambda-resources-pr-') }}
167-
uses: actions/checkout@v4
168-
with:
169-
ref: gh-pages
170-
path: gh-pages
171-
172163
- name: Update release tag in github pages
173164
if: ${{ !startsWith(inputs.STACK_NAME, 'epsam-pr-') }}
174165
run: |

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
needs: [get_commit_id, tag_release]
9999
uses: ./.github/workflows/cdk_package_code.yml
100100
with:
101+
STACK_NAME: epsam
101102
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
102103
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
103104

@@ -110,6 +111,7 @@ jobs:
110111
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
111112
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
112113
CDK_APP_NAME: EpsAssistMeApp
114+
DEPLOY_CODE: true
113115
LOG_RETENTION_IN_DAYS: 30
114116
LOG_LEVEL: DEBUG
115117
MARK_JIRA_RELEASED: false

.github/workflows/pull_request.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,22 @@ jobs:
5656
needs: [get_issue_number, get_commit_id]
5757
uses: ./.github/workflows/cdk_package_code.yml
5858
with:
59+
STACK_NAME: epsam
5960
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
6061
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
6162

6263
release_code:
6364
needs: [get_issue_number, package_code, get_commit_id]
6465
uses: ./.github/workflows/cdk_release_code.yml
6566
with:
66-
STACK_NAME: epsam-pr-${{needs.get_issue_number.outputs.issue_number}}
67+
STACK_NAME: epsam
6768
TARGET_ENVIRONMENT: dev-pr
6869
VERSION_NUMBER: PR-${{ needs.get_issue_number.outputs.issue_number }}
6970
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
7071
CDK_APP_NAME: EpsAssistMeApp
72+
DEPLOY_CODE: true
7173
LOG_RETENTION_IN_DAYS: 30
7274
LOG_LEVEL: DEBUG
73-
7475
secrets:
7576
CLOUD_FORMATION_DEPLOY_ROLE: ${{ secrets.DEV_CLOUD_FORMATION_DEPLOY_ROLE }}
7677
CDK_PULL_IMAGE_ROLE: ${{ secrets.DEV_CDK_PULL_IMAGE_ROLE }}

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
needs: [get_commit_id, tag_release]
118118
uses: ./.github/workflows/cdk_package_code.yml
119119
with:
120+
STACK_NAME: epsam
120121
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
121122
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
122123

@@ -129,6 +130,7 @@ jobs:
129130
VERSION_NUMBER: ${{ needs.tag_release.outputs.version_tag }}
130131
COMMIT_ID: ${{ needs.get_commit_id.outputs.commit_id }}
131132
CDK_APP_NAME: EpsAssistMeApp
133+
DEPLOY_CODE: true
132134
LOG_RETENTION_IN_DAYS: 30
133135
LOG_LEVEL: DEBUG
134136
secrets:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ _site/
2828
vendor
2929
.npmrc
3030
cdk.out
31+
.build

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
nodejs 22.12.0
2-
python 3.12.7
2+
python 3.13.3
33
poetry 1.8.3
44
shellcheck 0.10.0
55
direnv 2.32.2

.vscode/eps-assist-me.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
{
88
"name": "packages/cdk",
99
"path": "../packages/cdk"
10+
},
11+
{
12+
"name": "packages/createIndexFunction",
13+
"path": "../packages/createIndexFunction"
14+
},
15+
{
16+
"name": "packages/slackBotFunction",
17+
"path": "../packages/slackBotFunction"
1018
}
1119
],
1220
"settings": {

0 commit comments

Comments
 (0)