Skip to content

Commit ed4357e

Browse files
authored
Merge branch 'master' into dependabot/terraform/infrastructure/account/terraform-minor-patch-815482342b
2 parents 1a24177 + 6ce912d commit ed4357e

File tree

21 files changed

+2926
-3617
lines changed

21 files changed

+2926
-3617
lines changed

.github/workflows/deploy-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
run: make plan-ci
8484

8585
- name: Save Terraform Plan
86-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
86+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
8787
with:
8888
name: ${{ env.ENVIRONMENT }}-${{ env.SUB_ENVIRONMENT }}-tfplan
8989
path: infrastructure/instance/tfplan

.github/workflows/quality-checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ jobs:
247247
fi
248248
249249
- name: SonarCloud Scan
250-
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602
250+
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9
251251
env:
252252
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
253253
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

README.specification.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,39 @@ See the APM confluence for more information on how the [\_ping](https://nhsd-con
143143
This folder contains a template for a sandbox API. This example is a NodeJs application running in Docker. The application handles a few simple endpoints such as: /\_ping, /health, /\_status, /hello and some logging logic.
144144
For more information about building sandbox APIs see the [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Setting+up+your+API+sandbox).
145145

146+
### Testing the sandbox
147+
148+
The sandbox can be tested locally by changing to the `/sandbox` folder in a terminal and running `make run`. This will spin up a mock Prism web server at http://0.0.0.0:9000/.
149+
150+
From a separate terminal, test each endpoint as follows:
151+
152+
- Copy the appropriate `curl` command. These can be retrieved by opening the `specification/immunisation-fhir-api.yaml` file in the Swagger editor; expand the required endpoint, select 'Try it out', and then 'Execute'. The `curl` command to use will appear in the Curl window.
153+
154+
- Replace
155+
https://sandbox.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/ with http://0.0.0.0:9000/
156+
157+
- Add the -i option in order to see the response headers.
158+
159+
Examples:
160+
161+
- GET Search:
162+
163+
curl -i -X 'GET' \
164+
'http://0.0.0.0:9000/Immunization?patient.identifier=https%3A%2F%2Ffhir.nhs.uk%2FId%2Fnhs-number%7C9000000009&-immunization.target=3IN1&-date.from=1900-01-01&-date.to=9999-12-31&_include=Immunization%3Apatient' \
165+
-H 'accept: application/fhir+json' \
166+
-H 'X-Correlation-ID: 60E0B220-8136-4CA5-AE46-1D97EF59D068' \
167+
-H 'X-Request-ID: 60E0B220-8136-4CA5-AE46-1D97EF59D068'
168+
169+
- POST Search:
170+
171+
curl -i -X 'POST' \
172+
'http://0.0.0.0:9000/Immunization/_search' \
173+
-H 'accept: application/fhir+json' \
174+
-H 'X-Correlation-ID: 60E0B220-8136-4CA5-AE46-1D97EF59D068' \
175+
-H 'X-Request-ID: 60E0B220-8136-4CA5-AE46-1D97EF59D068' \
176+
-H 'Content-Type: application/x-www-form-urlencoded' \
177+
-d 'patient.identifier=https%3A%2F%2Ffhir.nhs.uk%2FId%2Fnhs-number%7C9000000009&-immunization.target=3IN1&-date.from=1900-01-01&-date.to=9999-12-31&\_include=Immunization%3Apatient'
178+
146179
#### `utilities/scripts`:
147180

148181
Contains useful scripts that are used throughout the project, for example in Makefile and Github workflows

infrastructure/instance/environments/prod/blue/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pds_environment = "prod"
55
batch_error_notifications_enabled = true
66
create_mesh_processor = true
77
has_sub_environment_scope = false
8+
dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key"

infrastructure/instance/environments/prod/green/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pds_environment = "prod"
55
batch_error_notifications_enabled = true
66
create_mesh_processor = true
77
has_sub_environment_scope = false
8+
dspp_kms_key_alias = "nhsd-dspp-core-prod-extended-attributes-gdp-key"

infrastructure/instance/file_name_processor.tf

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,44 @@ resource "aws_iam_policy" "filenameprocessor_dynamo_access_policy" {
253253
})
254254
}
255255

256+
# Kms policy setup on filenameprocessor lambda for dps cross account bucket access
257+
resource "aws_iam_policy" "filenameprocessor_dps_extended_attribute_kms_policy" {
258+
name = "${local.short_prefix}-filenameproc-dps-kms-policy"
259+
description = "Allow Lambda to use DPS KMS key for SSE-KMS encrypted S3 bucket access"
260+
261+
policy = jsonencode({
262+
Version = "2012-10-17"
263+
Statement = [
264+
{
265+
Effect = "Allow",
266+
Action = [
267+
"kms:Decrypt",
268+
"kms:GenerateDataKey",
269+
"kms:DescribeKey"
270+
],
271+
Resource = "arn:aws:kms:eu-west-2:${var.dspp_core_account_id}:key/*",
272+
"Condition" = {
273+
"ForAnyValue:StringEquals" = {
274+
"kms:ResourceAliases" = "alias/${var.dspp_kms_key_alias}"
275+
}
276+
}
277+
}
278+
]
279+
})
280+
}
256281

257282
# Attach the execution policy to the Lambda role
258283
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_exec_policy_attachment" {
259284
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
260285
policy_arn = aws_iam_policy.filenameprocessor_lambda_exec_policy.arn
261286
}
262287

288+
#Attach the dps kms policy to the Lambda role
289+
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_dps_kms_ea_policy_attachment" {
290+
role = aws_iam_role.filenameprocessor_lambda_exec_role.name
291+
policy_arn = aws_iam_policy.filenameprocessor_dps_extended_attribute_kms_policy.arn
292+
}
293+
263294
# Attach the SQS policy to the Lambda role
264295
resource "aws_iam_role_policy_attachment" "filenameprocessor_lambda_sqs_policy_attachment" {
265296
role = aws_iam_role.filenameprocessor_lambda_exec_role.name

infrastructure/instance/mesh_processor.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ resource "aws_ecr_repository" "mesh_file_converter_lambda_repository" {
3333
module "mesh_processor_docker_image" {
3434
count = var.create_mesh_processor ? 1 : 0
3535

36-
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
37-
version = "8.1.2"
36+
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
37+
version = "8.1.2"
38+
docker_file_path = "./mesh_processor/Dockerfile"
3839

3940
create_ecr_repo = false
4041
ecr_repo = aws_ecr_repository.mesh_file_converter_lambda_repository[0].name
@@ -57,9 +58,10 @@ module "mesh_processor_docker_image" {
5758

5859
platform = "linux/amd64"
5960
use_image_tag = false
60-
source_path = local.mesh_processor_lambda_dir
61+
source_path = abspath("${path.root}/../../lambdas")
6162
triggers = {
62-
dir_sha = local.mesh_processor_lambda_dir_sha
63+
dir_sha = local.mesh_processor_lambda_dir_sha
64+
shared_dir_sha = local.shared_dir_sha
6365
}
6466
}
6567

infrastructure/instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ variable "csoc_account_id" {
1010
default = "693466633220"
1111
}
1212

13+
variable "dspp_kms_key_alias" {
14+
description = "Alias name of the DPS KMS key allowed for SSE-KMS encryption"
15+
type = string
16+
default = "nhsd-dspp-core-ref-extended-attributes-gdp-key"
17+
}
18+
1319
variable "create_mesh_processor" {
1420
default = false
1521
}

lambdas/backend/src/controller/fhir_controller.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from service.fhir_service import FhirService, get_service_url
3737

3838
IMMUNIZATION_ENV = os.getenv("IMMUNIZATION_ENV")
39+
IMMUNIZATION_BASE_PATH = os.getenv("IMMUNIZATION_BASE_PATH")
3940

4041

4142
def make_controller(
@@ -51,7 +52,7 @@ def make_controller(
5152

5253
class FhirController:
5354
_IMMUNIZATION_ID_PATTERN = r"^[A-Za-z0-9\-.]{1,64}$"
54-
_API_SERVICE_URL = get_service_url()
55+
_API_SERVICE_URL = get_service_url(IMMUNIZATION_ENV, IMMUNIZATION_BASE_PATH)
5556

5657
def __init__(
5758
self,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"""Constants for the fhir_service layer"""
2+
3+
DEFAULT_BASE_PATH = "immunisation-fhir-api/FHIR/R4"
4+
PR_ENV_PREFIX = "pr-"

0 commit comments

Comments
 (0)