generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
CCM-12616 mesh poll retrieve #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lapenna-bjss
wants to merge
80
commits into
main
Choose a base branch
from
feature/CCM-12616_mesh_poll_retrieve
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
2562437
CCM-12616: Added py-mock-mesh module
gareth-allan 0da3abd
CCM-12616: Replaced mesh-poll Lambda with a skeleton Python version
gareth-allan b141b21
CCM-12616: test
lapenna-bjss 9876b1d
CCM-12616: add false positive to .gitleaksignore
lapenna-bjss 331d6c4
CCM-12616: fix sonarcloud issues
lapenna-bjss 2ed8cf1
CCM-12616: fix sonarcloud issues
lapenna-bjss 73fbd53
CCM-12616: Exclude mesh poll lambda from SonarCloud coverage temporarily
lapenna-bjss ce9e182
CCM-12616: add poetry install to pre.sh
lapenna-bjss cc83432
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss e02647d
CCM-12616: update .gitignore
lapenna-bjss dc0f7cf
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss 19b16de
CCM-12616: mesh-poll lambda
lapenna-bjss 29fa28c
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss 092fd3f
CCM-12616: terraform code
lapenna-bjss 94a2f08
CCM-12616: metric publisher
lapenna-bjss 8631401
CCM-12616: mock mesh only when enabled
lapenna-bjss bc10540
CCM-12616: add senderId to CloudEvent data
lapenna-bjss d1c9cd7
CCM-12616: mesh-download lambda
lapenna-bjss 51181ca
CCM-12616: add document_store tests
lapenna-bjss c045cc1
CCM-12616: update mesh download tests
lapenna-bjss 0e51120
CCM-12616: add S3 putObject statement for storing messages when mock …
lapenna-bjss 1054505
CCM-12616: add messageReference to the event data
lapenna-bjss d6dc913
CCM-12616: rename client to sender
lapenna-bjss f068287
CCM-12616: fix sonar issue
lapenna-bjss 3059592
CCM-12616: move docs dependencies to a separate make command
lapenna-bjss b43fed5
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss 0624e52
CCM-12616: update python runtime
lapenna-bjss 92ce87f
CCM-12616: update ssm prefixes with the correct paths
lapenna-bjss 904756a
CCM-12616: add shared MESH config
lapenna-bjss e024971
CCM-12616: update pipeline
lapenna-bjss 9a401da
CCM-12616: update config and tests
lapenna-bjss 7691746
CCM-12616: resolve comments
lapenna-bjss 0498402
CCM-12616: resolve comments
lapenna-bjss b0cf0c8
CCM-12616: fix pipeline issues
lapenna-bjss 360cdfb
CCM-12616: fix pipeline issues
lapenna-bjss 3589952
CCM-12616: test
lapenna-bjss ae8b458
CCM-12616: test
lapenna-bjss 4fd7343
CCM-12616: test
lapenna-bjss a912dae
CCM-12616: test
lapenna-bjss 0ace208
CCM-12616: test
lapenna-bjss 36b94ec
CCM-12616: revert changes
lapenna-bjss ff2e5b7
CCM-12616: test
lapenna-bjss eae4795
CCM-12616: test
lapenna-bjss e07f431
CCM-12616: test
lapenna-bjss 1ed06b2
CCM-12616: fix sonarcloud coverage issues
lapenna-bjss aa80734
CCM-12616: fix sonarcloud coverage issues
lapenna-bjss e8d06a0
CCM-12616: convert poetry to pip
lapenna-bjss 62035fb
CCM-12616: test
lapenna-bjss 8baf979
CCM-12616: test
lapenna-bjss 21e3c2e
CCM-12616: test
lapenna-bjss d312464
CCM-12616: add setup.py files
lapenna-bjss abcee60
CCM-12616: update coverage.xml paths
lapenna-bjss 5f559b8
CCM-12616: update coverage.xml paths
lapenna-bjss 9000b50
CCM-12616: update sonar-scanner.properties
lapenna-bjss b79e3d4
CCM-12616: update sonar-scanner.properties
lapenna-bjss 9c8741c
CCM-12616: remove poetry from pre.sh
lapenna-bjss 4656623
CCM-12616: fix Unsupported attribute error
lapenna-bjss f2061ab
CCM-12616: fix lambda env vars
lapenna-bjss 8a0b984
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss 590d3df
CCM-12616: skip build docs step
lapenna-bjss ff76bbc
CCM-12616: test deployment
lapenna-bjss bb0454e
CCM-12616: test deployment
lapenna-bjss 367c5e9
CCM-12616: Restore previously disabled pipeline steps
lapenna-bjss e3cfa1d
CCM-12616: Update Readme
lapenna-bjss bd975fb
CCM-12616: Update Makefile
lapenna-bjss 73278ca
CCM-12616: Update sonar properties
lapenna-bjss ca56d6e
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
lapenna-bjss 295dfe8
Merge branch 'main' into feature/CCM-12616_mesh_poll_retrieve
gareth-allan e2a1485
CCM-12616: Remove mesh-poll lambda from workspace Jest folders
gareth-allan 5b7ea7a
CCM-12616: Update events published to match latest schemas
gareth-allan b066e55
CCM-12616: Updated base CloudEvent model to match latest schemas
gareth-allan c7076d1
CCM-12616: Attempt to fix mesh-poll lambda's packaging
gareth-allan ebfb170
CCM-12616: Attempt to fix mesh-poll lambda entrypoint
gareth-allan 02e1566
CCM-12616: Another mesh-poll packaging tweak
gareth-allan 242e7c0
CCM-12616: Fix mesh-poll SSM parameters
gareth-allan a39f0f7
CCM-12616: Fix import module error
lapenna-bjss ee8fc7d
Merge branch 'feature/CCM-12616_mesh_poll_retrieve' of https://github…
lapenna-bjss 7bcdbb6
CCM-12616: Update runtime version
lapenna-bjss fe52cd2
CCM-12616: Test
lapenna-bjss 309c771
CCM-12616: Test
lapenna-bjss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
infrastructure/terraform/components/dl/cloudwatch_event_rule_mesh_inbox_message_received.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| resource "aws_cloudwatch_event_rule" "mesh_inbox_message_received" { | ||
| name = "${local.csi}-mesh-inbox-message-received" | ||
| description = "Route MESHInboxMessageReceived events from mesh-poll lambda to mesh-download queue" | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
|
|
||
| event_pattern = jsonencode({ | ||
| "detail" : { | ||
| "type" : [ | ||
| "uk.nhs.notify.digital.letters.mesh.inbox.message.received.v1" | ||
| ], | ||
| "dataschemaversion" : [{ | ||
| "prefix" : "1." | ||
| }] | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| # EventBridge target to send events to SQS queue | ||
| resource "aws_cloudwatch_event_target" "mesh_download_sqs" { | ||
| rule = aws_cloudwatch_event_rule.mesh_inbox_message_received.name | ||
| target_id = "mesh-inbox-message-received-sqs-target" | ||
| arn = module.sqs_mesh_download.sqs_queue_arn | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
| } |
10 changes: 10 additions & 0 deletions
10
infrastructure/terraform/components/dl/lambda_event_source_mapping_mesh_download.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| resource "aws_lambda_event_source_mapping" "mesh_download" { | ||
| event_source_arn = module.sqs_mesh_download.sqs_queue_arn | ||
| function_name = module.mesh_download.function_name | ||
| batch_size = var.queue_batch_size | ||
| maximum_batching_window_in_seconds = var.queue_batch_window_seconds | ||
|
|
||
| function_response_types = [ | ||
| "ReportBatchItemFailures" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
infrastructure/terraform/components/dl/module_lambda_mesh_download.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| module "mesh_download" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-lambda.zip" | ||
|
|
||
| function_name = "mesh-download" | ||
| description = "A lambda function for downloading MESH messages and storing in S3" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = local.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| log_retention_in_days = var.log_retention_in_days | ||
| kms_key_arn = module.kms.key_arn | ||
|
|
||
| iam_policy_document = { | ||
| body = data.aws_iam_policy_document.mesh_download_lambda.json | ||
| } | ||
|
|
||
| function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"] | ||
| function_code_base_path = local.aws_lambda_functions_dir_path | ||
| function_code_dir = "mesh-download/target/dist" | ||
| function_include_common = true | ||
| function_module_name = "mesh_download" | ||
| handler_function_name = "handler.handler" | ||
| runtime = "python3.14" | ||
| memory = 256 | ||
| timeout = 60 | ||
| log_level = var.log_level | ||
|
|
||
| force_lambda_code_deploy = var.force_lambda_code_deploy | ||
| enable_lambda_insights = false | ||
|
|
||
| send_to_firehose = true | ||
| log_destination_arn = local.log_destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| lambda_env_vars = { | ||
| SSM_PREFIX = "/dl/${var.environment}/mesh" | ||
| EVENT_PUBLISHER_EVENT_BUS_ARN = aws_cloudwatch_event_bus.main.arn | ||
| EVENT_PUBLISHER_DLQ_URL = module.sqs_event_publisher_errors.sqs_queue_url | ||
| ENVIRONMENT = var.environment | ||
| PII_BUCKET = module.s3bucket_pii_data.bucket | ||
| CERTIFICATE_EXPIRY_METRIC_NAME = "mesh-download-client-certificate-near-expiry" | ||
| CERTIFICATE_EXPIRY_METRIC_NAMESPACE = "dl-mesh-download" | ||
| DOWNLOAD_METRIC_NAME = "mesh-download-successful-downloads" | ||
| DOWNLOAD_METRIC_NAMESPACE = "dl-mesh-download" | ||
| USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false" | ||
| } | ||
|
|
||
| } | ||
|
|
||
| data "aws_iam_policy_document" "mesh_download_lambda" { | ||
| # Mock S3 ListBucket only when enabled | ||
| dynamic "statement" { | ||
| for_each = var.enable_mock_mesh ? [1] : [] | ||
| content { | ||
| sid = "MockMeshListBucket" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:ListBucket" | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.s3bucket_non_pii_data.arn | ||
| ] | ||
|
|
||
| condition { | ||
| test = "StringLike" | ||
| variable = "s3:prefix" | ||
| values = ["mock-mesh/*"] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Mock S3 GetObject only when enabled | ||
| dynamic "statement" { | ||
| for_each = var.enable_mock_mesh ? [1] : [] | ||
| content { | ||
| sid = "MockMeshGetObject" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:GetObject" | ||
| ] | ||
|
|
||
| resources = [ | ||
| "${module.s3bucket_non_pii_data.arn}/mock-mesh/*" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| statement { | ||
| sid = "KMSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.kms.key_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "S3BucketPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:PutObject", | ||
| "s3:GetObject", | ||
| ] | ||
|
|
||
| resources = [ | ||
| "${module.s3bucket_pii_data.arn}/*", | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SQSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:ReceiveMessage", | ||
| "sqs:DeleteMessage", | ||
| "sqs:GetQueueAttributes", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_mesh_download.sqs_queue_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "EventBridgePermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "events:PutEvents", | ||
| ] | ||
|
|
||
| resources = [ | ||
| aws_cloudwatch_event_bus.main.arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "DLQPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:SendMessage", | ||
| "sqs:SendMessageBatch", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_event_publisher_errors.sqs_queue_arn, | ||
| ] | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.