Skip to content

Commit de5534c

Browse files
committed
tidy
1 parent 1bc307c commit de5534c

19 files changed

+229
-624
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
2525
| `recordprocessor` | **Imms Batch** – Handles batch record processing. |
2626
| `redis_sync` | **Imms Redis** – Handles sync s3 to REDIS. |
2727
| `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 |
2929
---
3030

3131
### Pipelines
@@ -74,22 +74,22 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
7474
- `pyenv` manages multiple Python versions at the system level, allowing you to install and switch between different Python versions for different projects.
7575
- `direnv` automates the loading of environment variables and can auto-activate virtual environments (.venv) when entering a project directory, making workflows smoother.
7676
- `.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.
7878

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.
8181

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.
8383

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.
8585

8686
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.
8787

8888
## Environment setup
8989
These dependencies are required for running and debugging the Lambda functions and end-to-end (E2E) tests.
9090

91-
### Install dependencies
92-
Steps:
91+
### Install dependencies
92+
Steps:
9393
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/).
9494
2. Install the following tools inside WSL. These will be used by the lambda and infrastructure code:
9595
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
@@ -119,7 +119,7 @@ Once connected, you should see the path as something similar to: `/mnt/d/Source/
119119
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
120120
```
121121
122-
7. Install poetry
122+
7. Install poetry
123123
```
124124
pip install poetry
125125
```
@@ -129,7 +129,7 @@ The steps below must be performed in each Lambda function folder and e2e folder
129129
130130
For detailed instructions on running individual Lambdas, refer to the README.md files located inside each respective Lambda folder.
131131
132-
Steps:
132+
Steps:
133133
1. Set the python version in the folder with the code used by lambda for example `./backend` (see [lambdas](#lambdas)) folder.
134134
```
135135
pyenv local 3.11.13 # Set version in backend (this creates a .python-version file)
@@ -158,7 +158,7 @@ Steps:
158158
dotenv
159159
```
160160
161-
5. Restart bash and run `direnv allow`. You should see something similar like:
161+
5. Restart bash and run `direnv allow`. You should see something similar like:
162162
```
163163
direnv: loading /mnt/d/Source/immunisation-fhir-api/.envrc
164164
direnv: export +AWS_PROFILE +IMMUNIZATION_ENV +VIRTUAL_ENV ~PATH
@@ -167,15 +167,15 @@ Steps:
167167
168168
### Setting up the root level environment
169169
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).
172172
**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.
173173
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.**
174174
2. Run `make lint`. This will:
175175
- Check the linting of the API specification yaml.
176176
- Run Flake8 on all Python files in the repository, excluding files inside .venv and .terraform directories.
177177
178-
## IDE setup
178+
## IDE setup
179179
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.
180180
181181
### VS Code
@@ -209,7 +209,7 @@ The root (`immunisation-fhir-api`) should point to `/mnt/d/Source/immunisation-f
209209
210210
211211
## 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.
213213
To set up a GPG key please follow the instructions specified here:
214214
https://docs.github.com/en/authentication/managing-commit-signature-verification
215215

azure/templates/deploy-stage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ jobs:
150150
echo "##vso[task.setvariable variable=FULLY_QUALIFIED_SERVICE_NAME]${FULLY_QUALIFIED_SERVICE_NAME}"
151151
fi
152152
displayName: Override FULLY_QUALIFIED_SERVICE_NAME
153+
153154
- checkout: self
154155
path: "s/${{ parameters.service_name }}"
155156

lambdas/id_sync/README.md

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,35 @@
1-
# Redis Sync Lambda
1+
# Id_Sync Lambda
22

33
## Overview
44

5-
**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.
66

77
## Features
88

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..
1211
- **Logging:** Provides detailed logging for monitoring and troubleshooting.
1312

1413
## How It Works
1514

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.
2119

2220
## Configuration
2321

2422
- **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
3526

3627
## Development
3728

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.
4031
- Use the provided Makefile and Dockerfile for building, testing, and packaging.
4132

4233
## License
4334

44-
This project is maintained by NHS. See [LICENSE](../LICENSE) for details.
35+
This project is maintained by NHS. See [LICENSE](../LICENSE) for details.

lambdas/id_sync/src/junk.json

Lines changed: 0 additions & 129 deletions
This file was deleted.

lambdas/id_sync/src/os_vars.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# os_vars.py - Improved approach (✅ Better)
21
import os
32
from typing import Optional
43

0 commit comments

Comments
 (0)