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: terraform/README.md
+20-3Lines changed: 20 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,10 +42,11 @@ All components live inside a private VPC (no NAT gateway, no internet gateway).
42
42
43
43
-**ECR Repository** (`aws_ecr_repository.ttc_lambda`): Stores the Docker container image for the main TTC Lambda. The image installs all workspace Python packages (`shared-models`, `lambda-handler`, `text-to-code`, `text-to-code-lambda`) and bakes in the SentenceTransformer model (`intfloat/e5-large-v2`) at build time. Images are built and pushed by CI/CD during `terraform apply`.
44
44
-**ECR Repository** (`aws_ecr_repository.index_lambda`): Stores the Docker container image for the index bootstrap Lambda, built from `Dockerfile.index` at repo root.
45
+
-**ECR Repository** (`aws_ecr_repository.augmentation_lambda`): Stores the Docker container image for the augmentation Lambda, built from `Dockerfile.augmentation` at repo root.
45
46
46
47
### IAM (`main.tf`)
47
48
48
-
-**Lambda IAM Role** (`aws_iam_role.lambda_role`): Shared by both Lambda functions. Attached policies:
49
+
-**Lambda IAM Role** (`aws_iam_role.lambda_role`): Shared by all Lambda functions (TTC, index, and augmentation). Attached policies:
49
50
-`AWSLambdaVPCAccessExecutionRole` — allows ENI creation for VPC placement
Deployed as a **container image** from ECR (`package_type = "Image"`). The Docker image (`Dockerfile.augmentation` at repo root) installs the `augmentation-lambda` package along with its workspace dependencies (`shared-models`, `lambda-handler`, `augmentation`).
81
+
82
+
At runtime, the Lambda processes augmentation requests containing eICR XML and nonstandard code mappings from the TTC Lambda. It:
83
+
84
+
1. Parses incoming eICR XML and nonstandard code instances
85
+
2. Inserts standardized LOINC/SNOMED `<translation>` elements into the eICR
4. Writes the augmented eICR XML and metadata JSON to S3
88
+
89
+
The augmentation Lambda uses only the Lambda security group (not the OpenSearch security group) since it does not require OpenSearch access. It is configured with lower memory (512 MB) and timeout (300s) defaults compared to the TTC Lambda, as it does not load ML models.
90
+
91
+
Environment variables injected at deploy time: `S3_BUCKET`, `AUGMENTED_EICR_PREFIX`, `AUGMENTATION_METADATA_PREFIX`, `REGION`.
92
+
77
93
### OpenSearch Ingestion Pipeline (`main.tf`)
78
94
79
95
An **AWS OpenSearch Ingestion Service (OSIS)** pipeline (`aws_osis_pipeline.ttc_ingestion_pipeline`) that:
@@ -91,13 +107,14 @@ The pipeline **depends on** the index bootstrap invocation completing first, ens
91
107
Terraform manages dependency ordering automatically, but conceptually the sequence is:
92
108
93
109
1. VPC, subnets, security groups, S3 endpoint created
94
-
2. ECR repositories created (TTC lambda + index lambda)
110
+
2. ECR repositories created (TTC lambda, index lambda, augmentation lambda)
95
111
3. Docker images built and pushed to ECR (in CI/CD, before full `terraform apply`)
96
112
4. OpenSearch domain and VPC endpoint created
97
113
5. Lambda IAM role created
98
114
6. Index bootstrap Lambda deployed and **immediately invoked** — creates the KNN index in OpenSearch
99
115
7. Ingestion pipeline deployed — begins polling S3 for NDJSON embeddings to load
100
116
8. Main TTC Lambda deployed with container image from ECR — loads model at cold start, ready to serve KNN queries
117
+
9. Augmentation Lambda deployed with container image from ECR — ready to process augmentation requests
101
118
102
119
## State Backend
103
120
@@ -134,7 +151,7 @@ Before running `terraform apply`:
134
151
135
152
1.**Bootstrap**: Run `terraform apply` in `bootstrap/` first to create the S3 state bucket and DynamoDB lock table.
136
153
2.**Embedding files**: Upload NDJSON embedding files to `s3://dibbs-text-to-code/ingestion/`. The OSIS pipeline will ingest these into OpenSearch.
137
-
3.**Docker**: CI/CD builds both container images (`Dockerfile.ttc` for TTC lambda, `Dockerfile.index` for index lambda) automatically. For local development, Docker must be available to build the images.
154
+
3.**Docker**: CI/CD builds all container images (`Dockerfile.ttc` for TTC lambda, `Dockerfile.index` for index lambda, `Dockerfile.augmentation` for augmentation lambda) automatically. For local development, Docker must be available to build the images.
138
155
139
156
> **Note:** The SentenceTransformer model and heavy Python dependencies (sentence-transformers, torch) are baked into the Lambda container image at build time via the Dockerfile. The Dockerfile installs the real `text-to-code-lambda` package and all its workspace dependencies.
0 commit comments