Skip to content

Commit 571608e

Browse files
CCM-12875: PDM Mock (#131)
1 parent 867a096 commit 571608e

35 files changed

+2097
-0
lines changed

infrastructure/terraform/components/dl/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ No requirements.
1717
| <a name="input_component"></a> [component](#input\_component) | The variable encapsulating the name of this component | `string` | `"dl"` | no |
1818
| <a name="input_default_tags"></a> [default\_tags](#input\_default\_tags) | A map of default tags to apply to all taggable resources within the component | `map(string)` | `{}` | no |
1919
| <a name="input_enable_dynamodb_delete_protection"></a> [enable\_dynamodb\_delete\_protection](#input\_enable\_dynamodb\_delete\_protection) | Enable DynamoDB Delete Protection on all Tables | `bool` | `true` | no |
20+
| <a name="input_enable_pdm_mock"></a> [enable\_pdm\_mock](#input\_enable\_pdm\_mock) | Flag indicating whether to deploy PDM mock API (should be false in production environments) | `bool` | `true` | no |
2021
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
2122
| <a name="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy) | Flag to force deletion of S3 buckets | `bool` | `false` | no |
2223
| <a name="input_force_lambda_code_deploy"></a> [force\_lambda\_code\_deploy](#input\_force\_lambda\_code\_deploy) | If the lambda package in s3 has the same commit id tag as the terraform build branch, the lambda will not update automatically. Set to True if making changes to Lambda code from on the same commit for example during development | `bool` | `false` | no |
@@ -26,6 +27,8 @@ No requirements.
2627
| <a name="input_log_retention_in_days"></a> [log\_retention\_in\_days](#input\_log\_retention\_in\_days) | The retention period in days for the Cloudwatch Logs events to be retained, default of 0 is indefinite | `number` | `0` | no |
2728
| <a name="input_mesh_poll_schedule"></a> [mesh\_poll\_schedule](#input\_mesh\_poll\_schedule) | Schedule to poll MESH for messages | `string` | `"cron(0,30 8-16 ? * MON-FRI *)"` | no |
2829
| <a name="input_parent_acct_environment"></a> [parent\_acct\_environment](#input\_parent\_acct\_environment) | Name of the environment responsible for the acct resources used, affects things like DNS zone. Useful for named dev environments | `string` | `"main"` | no |
30+
| <a name="input_pdm_mock_access_token"></a> [pdm\_mock\_access\_token](#input\_pdm\_mock\_access\_token) | Mock access token for PDM API authentication (used in local/dev environments) | `string` | `"mock-pdm-token"` | no |
31+
| <a name="input_pdm_use_non_mock_token"></a> [pdm\_use\_non\_mock\_token](#input\_pdm\_use\_non\_mock\_token) | Whether to use the shared APIM access token from SSM (/component/environment/apim/access\_token) instead of the mock token | `bool` | `false` | no |
2932
| <a name="input_project"></a> [project](#input\_project) | The name of the tfscaffold project | `string` | n/a | yes |
3033
| <a name="input_queue_batch_size"></a> [queue\_batch\_size](#input\_queue\_batch\_size) | maximum number of queue items to process | `number` | `10` | no |
3134
| <a name="input_queue_batch_window_seconds"></a> [queue\_batch\_window\_seconds](#input\_queue\_batch\_window\_seconds) | maximum time in seconds between processing events | `number` | `10` | no |
@@ -40,6 +43,7 @@ No requirements.
4043
| <a name="module_lambda_apim_key_generation"></a> [lambda\_apim\_key\_generation](#module\_lambda\_apim\_key\_generation) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4144
| <a name="module_lambda_lambda_apim_refresh_token"></a> [lambda\_lambda\_apim\_refresh\_token](#module\_lambda\_lambda\_apim\_refresh\_token) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4245
| <a name="module_mesh_poll"></a> [mesh\_poll](#module\_mesh\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
46+
| <a name="module_pdm_mock"></a> [pdm\_mock](#module\_pdm\_mock) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4347
| <a name="module_pdm_uploader"></a> [pdm\_uploader](#module\_pdm\_uploader) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip | n/a |
4448
| <a name="module_s3bucket_cf_logs"></a> [s3bucket\_cf\_logs](#module\_s3bucket\_cf\_logs) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip | n/a |
4549
| <a name="module_s3bucket_letters"></a> [s3bucket\_letters](#module\_s3bucket\_letters) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip | n/a |
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
resource "aws_api_gateway_deployment" "pdm_mock" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
depends_on = [
5+
aws_api_gateway_integration.create_document_reference,
6+
aws_api_gateway_integration.get_document_reference,
7+
]
8+
9+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
10+
11+
triggers = {
12+
redeployment = sha1(jsonencode([
13+
aws_api_gateway_resource.patient_data_manager[0].id,
14+
aws_api_gateway_resource.fhir[0].id,
15+
aws_api_gateway_resource.r4[0].id,
16+
aws_api_gateway_resource.document_reference[0].id,
17+
aws_api_gateway_resource.document_reference_id[0].id,
18+
aws_api_gateway_method.create_document_reference[0].id,
19+
aws_api_gateway_method.get_document_reference[0].id,
20+
aws_api_gateway_integration.create_document_reference[0].id,
21+
aws_api_gateway_integration.get_document_reference[0].id,
22+
]))
23+
}
24+
25+
lifecycle {
26+
create_before_destroy = true
27+
}
28+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "aws_api_gateway_integration" "create_document_reference" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
resource_id = aws_api_gateway_resource.document_reference[0].id
6+
http_method = aws_api_gateway_method.create_document_reference[0].http_method
7+
8+
integration_http_method = "POST"
9+
type = "AWS_PROXY"
10+
uri = module.pdm_mock[0].function_invoke_arn
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "aws_api_gateway_integration" "get_document_reference" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
resource_id = aws_api_gateway_resource.document_reference_id[0].id
6+
http_method = aws_api_gateway_method.get_document_reference[0].http_method
7+
8+
integration_http_method = "POST"
9+
type = "AWS_PROXY"
10+
uri = module.pdm_mock[0].function_invoke_arn
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_api_gateway_method" "create_document_reference" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
resource_id = aws_api_gateway_resource.document_reference[0].id
6+
http_method = "POST"
7+
authorization = "AWS_IAM"
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_api_gateway_method" "get_document_reference" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
resource_id = aws_api_gateway_resource.document_reference_id[0].id
6+
http_method = "GET"
7+
authorization = "AWS_IAM"
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_api_gateway_resource" "document_reference" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
parent_id = aws_api_gateway_resource.r4[0].id
6+
path_part = "DocumentReference"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_api_gateway_resource" "document_reference_id" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
parent_id = aws_api_gateway_resource.document_reference[0].id
6+
path_part = "{id}"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_api_gateway_resource" "fhir" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
parent_id = aws_api_gateway_resource.patient_data_manager[0].id
6+
path_part = "FHIR"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "aws_api_gateway_resource" "patient_data_manager" {
2+
count = local.deploy_pdm_mock ? 1 : 0
3+
4+
rest_api_id = aws_api_gateway_rest_api.pdm_mock[0].id
5+
parent_id = aws_api_gateway_rest_api.pdm_mock[0].root_resource_id
6+
path_part = "patient-data-manager"
7+
}

0 commit comments

Comments
 (0)