You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
25
25
|`recordprocessor`|**Imms Batch** – Handles batch record processing. |
26
26
|`redis_sync`|**Imms Redis** – Handles sync s3 to REDIS. |
27
27
|`id_sync`|**Imms Redis** – Handles sync SQS to IEDS. |
28
-
|`id_sync`|**Imms Redis** – Not a lambda but Shared Code for lambdas |
28
+
|`shared`|**Imms Redis** – Not a lambda but Shared Code for lambdas |
29
29
---
30
30
31
31
### Pipelines
@@ -74,22 +74,22 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
74
74
-`pyenv` manages multiple Python versions at the system level, allowing you to install and switch between different Python versions for different projects.
75
75
-`direnv` automates the loading of environment variables and can auto-activate virtual environments (.venv) when entering a project directory, making workflows smoother.
76
76
-`.venv` (created via python -m venv or poetry) is Python’s built-in tool for isolating dependencies per project, ensuring that packages don’t interfere with global Python packages.
77
-
-`Poetry` is an all-in-one dependency and virtual environment manager that automatically creates a virtual environment (.venv), manages package installations, and locks dependencies (poetry.lock) for reproducibility, making it superior to using pip manually and it is used in all the lambda projects.
77
+
-`Poetry` is an all-in-one dependency and virtual environment manager that automatically creates a virtual environment (.venv), manages package installations, and locks dependencies (poetry.lock) for reproducibility, making it superior to using pip manually and it is used in all the lambda projects.
78
78
79
-
## Project structure
80
-
To support a modular and maintainable architecture, each Lambda function in this project is structured as a self-contained folder with its own dependencies, configuration, and environment.
79
+
## Project structure
80
+
To support a modular and maintainable architecture, each Lambda function in this project is structured as a self-contained folder with its own dependencies, configuration, and environment.
81
81
82
-
We use Poetry to manage dependencies and virtual environments, with the virtualenvs.in-project setting enabled to ensure each Lambda has an isolated `.venv` created within its folder.
82
+
We use Poetry to manage dependencies and virtual environments, with the virtualenvs.in-project setting enabled to ensure each Lambda has an isolated `.venv` created within its folder.
83
83
84
-
Additionally, direnv is used alongside `.envrc` and `.env` files to automatically activate the appropriate virtual environment and load environment-specific variables when entering a folder.
84
+
Additionally, direnv is used alongside `.envrc` and `.env` files to automatically activate the appropriate virtual environment and load environment-specific variables when entering a folder.
85
85
86
86
Each Lambda folder includes its own `.env` file for Lambda-specific settings, while the project root contains a separate `.env` and `.venv` for managing shared tooling, scripts, or infrastructure-related configurations. This setup promotes clear separation of concerns, reproducibility across environments, and simplifies local development, testing, and packaging for deployment.
87
87
88
88
## Environment setup
89
89
These dependencies are required for running and debugging the Lambda functions and end-to-end (E2E) tests.
90
90
91
-
### Install dependencies
92
-
Steps:
91
+
### Install dependencies
92
+
Steps:
93
93
1. Install [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) if running on Windows and install [Docker](https://docs.docker.com/engine/install/).
94
94
2. Install the following tools inside WSL. These will be used by the lambda and infrastructure code:
The root-level virtual environment is primarily used for linting, as we create separate virtual environments for each folder that contains Lambda functions.
170
-
Steps:
171
-
1. Follow instructions above to [install dependencies](#install-dependencies) & [set up a virtual environment](#setting-up-a-virtual-environment-with-poetry).
170
+
Steps:
171
+
1. Follow instructions above to [install dependencies](#install-dependencies) & [set up a virtual environment](#setting-up-a-virtual-environment-with-poetry).
172
172
**Note: While this project uses Python 3.10 (e.g. for Lambdas), the NHSDigital/api-management-utils repository — which orchestrates setup and linting — defaults to Python 3.8.
173
173
The linting command is executed from within that repo but calls the Makefile in this project, so be aware of potential Python version mismatches when running or debugging locally or in the pipeline.**
174
174
2. Run `make lint`. This will:
175
175
- Check the linting of the API specification yaml.
176
176
- Run Flake8 on all Python files in the repository, excluding files inside .venv and .terraform directories.
177
177
178
-
## IDE setup
178
+
## IDE setup
179
179
The current team uses VS Code mainly. So this setup is targeted towards VS code. If you use another IDE please add the documentation to set up workspaces here.
180
180
181
181
### VS Code
@@ -209,7 +209,7 @@ The root (`immunisation-fhir-api`) should point to `/mnt/d/Source/immunisation-f
209
209
210
210
211
211
## Verified commits
212
-
Please note that this project requires that all commits are verified using a GPG key.
212
+
Please note that this project requires that all commits are verified using a GPG key.
213
213
To set up a GPG key please follow the instructions specified here:
**Redis Sync** is an AWS Lambda function designed to monitor a configuration S3 bucket and synchronize its contents with an ElastiCache Redis instance. Whenever a new configuration file is uploaded or updated in the S3 bucket, the Lambda function processes the file, applies any required transformations, and uploads the result to the Redis cache.
5
+
**Id Sync** is an AWS Lambda function designed to trigger from SQS. It receives a list of NHS Numbers and checks for changes in PDS. If change found, it updates the Events Table.
6
6
7
7
## Features
8
8
9
-
-**S3 Event Driven:** Automatically triggered by S3 events (e.g., file uploads or updates) in the config bucket.
10
-
-**Transformation Support:** Applies custom transformation logic to configuration files before caching.
11
-
-**Redis Integration:** Uploads processed configuration data to ElastiCache Redis for fast, centralized access.
9
+
-**SQS Event Driven:** Automatically triggered by SQS event.
10
+
-**DynamoDb Integration:** Reviews contents of DynbamoDb Events table and updates where required..
12
11
-**Logging:** Provides detailed logging for monitoring and troubleshooting.
13
12
14
13
## How It Works
15
14
16
-
1.**S3 Event Trigger:** The Lambda is triggered by S3 events on the config bucket.
17
-
2.**File Processing:** The Lambda reads the new or updated file from S3.
18
-
3.**Transformation:** If required, the file content is transformed to the appropriate format.
19
-
4.**Redis Upload:** The transformed data is uploaded to the Redis cache under a key corresponding to the file.
20
-
5.**Monitoring:** Logs are generated for each step, aiding in monitoring and debugging.
15
+
1.**SQS Event Trigger:** The Lambda is triggered by SQS events.
16
+
2.**File Processing:** The Lambda reads the NHS Number from SQS.
17
+
3.**DynamoDb Update:** If a new NHS Number is returned from PDS, all relevant records are updated with new value.
18
+
4.**Monitoring:** Logs are generated for each step, aiding in monitoring and debugging.
21
19
22
20
## Configuration
23
21
24
22
-**Environment Variables:**
25
-
-`CONFIG_BUCKET_NAME`: Name of the S3 bucket to monitor.
26
-
-`AWS_REGION`: AWS region for S3 and Redis.
27
-
-`REDIS_HOST`: Redis endpoint.
28
-
-`REDIS_PORT`: Redis port (default: 6379).
29
-
30
-
## Usage
31
-
32
-
1.**Deploy the Lambda** using your preferred IaC tool (e.g., Terraform, AWS SAM).
33
-
2.**Configure S3 event notifications** to trigger the Lambda on object creation or update.
34
-
3.**Ensure Redis and S3 permissions** are set for the Lambda execution role.
23
+
-`IEDS_TABLE_NAME`: Name of events table.
24
+
-`PDS_ENV`: Targeted PDS service environment, eg INT.
25
+
-`SPLUNK_FIREHOSE_NAME`: Name of the splunk firehose for logging
35
26
36
27
## Development
37
28
38
-
- Code is located in the `src/` directory.
39
-
- Unit tests are in the `tests/` directory.
29
+
- Code is located in the `lambdas/id_sync/src/` directory.
30
+
- Unit tests are in the `lambdas/id_sync/tests/` directory.
40
31
- Use the provided Makefile and Dockerfile for building, testing, and packaging.
41
32
42
33
## License
43
34
44
-
This project is maintained by NHS. See [LICENSE](../LICENSE) for details.
35
+
This project is maintained by NHS. See [LICENSE](../LICENSE) for details.
0 commit comments