Skip to content

Commit 1190fab

Browse files
committed
wip
1 parent efa0c35 commit 1190fab

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ See https://nhsd-confluence.digital.nhs.uk/display/APM/Glossary.
2424
| `mesh_processor` | **Imms Batch** – MESH-specific batch processing functionality. |
2525
| `recordprocessor` | **Imms Batch** – Handles batch record processing. |
2626
| `redis_sync` | **Imms Redis** – Handles sync s3 to REDIS. |
27-
| `id_sync` | **Imms Redis** – Handles sync SQS to IEDS. |
27+
| `id_sync` | **Imms Redis** – Handles sync SQS to IEDS. |
28+
| `id_sync` | **Imms Redis** – Not a lambda but Shared Code for lambdas |
2829
---
2930

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

78-
## Project structure
79-
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.
8081

81-
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.
8283

83-
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.
8485

8586
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.
8687

8788
## Environment setup
8889
These dependencies are required for running and debugging the Lambda functions and end-to-end (E2E) tests.
8990

90-
### Install dependencies
91-
Steps:
91+
### Install dependencies
92+
Steps:
9293
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/).
9394
2. Install the following tools inside WSL. These will be used by the lambda and infrastructure code:
9495
- [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
@@ -118,7 +119,7 @@ Once connected, you should see the path as something similar to: `/mnt/d/Source/
118119
echo 'eval "$(direnv hook bash)"' >> ~/.bashrc
119120
```
120121
121-
7. Install poetry
122+
7. Install poetry
122123
```
123124
pip install poetry
124125
```
@@ -128,7 +129,7 @@ The steps below must be performed in each Lambda function folder and e2e folder
128129
129130
For detailed instructions on running individual Lambdas, refer to the README.md files located inside each respective Lambda folder.
130131
131-
Steps:
132+
Steps:
132133
1. Set the python version in the folder with the code used by lambda for example `./backend` (see [lambdas](#lambdas)) folder.
133134
```
134135
pyenv local 3.11.13 # Set version in backend (this creates a .python-version file)
@@ -157,7 +158,7 @@ Steps:
157158
dotenv
158159
```
159160
160-
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:
161162
```
162163
direnv: loading /mnt/d/Source/immunisation-fhir-api/.envrc
163164
direnv: export +AWS_PROFILE +IMMUNIZATION_ENV +VIRTUAL_ENV ~PATH
@@ -166,15 +167,15 @@ Steps:
166167
167168
### Setting up the root level environment
168169
The root-level virtual environment is primarily used for linting, as we create separate virtual environments for each folder that contains Lambda functions.
169-
Steps:
170-
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).
171172
**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.
172173
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.**
173174
2. Run `make lint`. This will:
174175
- Check the linting of the API specification yaml.
175176
- Run Flake8 on all Python files in the repository, excluding files inside .venv and .terraform directories.
176177
177-
## IDE setup
178+
## IDE setup
178179
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.
179180
180181
### VS Code
@@ -208,7 +209,7 @@ The root (`immunisation-fhir-api`) should point to `/mnt/d/Source/immunisation-f
208209
209210
210211
## Verified commits
211-
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.
212213
To set up a GPG key please follow the instructions specified here:
213214
https://docs.github.com/en/authentication/managing-commit-signature-verification
214215

lambdas/id_sync/src/ieds_db_operations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from boto3.dynamodb.conditions import Key
22
from os_vars import get_ieds_table_name
3-
from common.aws_dynamodb import get_delta_table
3+
from common.aws_dynamodb import get_dynamodb_table
44
from common.clients import logger
55

66
ieds_table = None
@@ -11,7 +11,7 @@ def get_ieds_table():
1111
global ieds_table
1212
if ieds_table is None:
1313
ieds_tablename = get_ieds_table_name()
14-
ieds_table = get_delta_table(ieds_tablename)
14+
ieds_table = get_dynamodb_table(ieds_tablename)
1515
return ieds_table
1616

1717

lambdas/shared/src/common/aws_dynamodb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from common.clients import dynamodb_client, logger
1+
from common.clients import dynamodb_resource, logger
22

33

4-
def get_delta_table(table_name):
4+
def get_dynamodb_table(table_name):
55
"""
66
Initialize the DynamoDB table resource with exception handling.
77
"""
88
try:
99
logger.info("Initializing table: %s", table_name)
10-
delta_table = dynamodb_client.Table(table_name)
10+
delta_table = dynamodb_resource.Table(table_name)
1111
except Exception as e:
1212
logger.exception("Error initializing DynamoDB table: %s", table_name)
1313
raise e

lambdas/shared/src/common/clients.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
# boto_config = Config(region_name=REGION_NAME)
1919
# secretsmanager_client = boto3_client("secretsmanager", config=boto_config)
2020
secrets_manager_client = boto3_client("secretsmanager", region_name=REGION_NAME)
21-
dynamodb_client = boto3.resource("dynamodb", region_name=REGION_NAME)
21+
dynamodb_resource = boto3.resource("dynamodb", region_name=REGION_NAME)

0 commit comments

Comments
 (0)