generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
CCM-13278: Confirm that we have received a file from a Trust #171
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
eff74d0
CCM-13278: Create skeleton mesh-acknowledge lambda
gareth-allan f507c23
CCM-13278: Add Terraform for mesh-acknowledge lambda
gareth-allan 2c856d1
CCM-13278: Add data.meshMessageId field to MESHInboxMessageDownloaded
gareth-allan 5d72645
CCM-13278: Add component tests for MESH acknowledger
gareth-allan b66f602
CCM-13278: Update VSCode workspace config
gareth-allan 471f603
CCM-13278: Add Python utilities
gareth-allan 92f86cc
CCM-13278: Add Python sender lookup utility
gareth-allan b1a6b60
CCM-13278: Implement mesh-acknowledge lambda
gareth-allan d1b6379
Merge branch 'main' into feature/CCM-13278_mesh_acknowledge
simonlabarere 4c7c531
Merge branch 'main' into feature/CCM-13278_mesh_acknowledge
simonlabarere 588d8a6
CCM-13278: Fix code duplication
simonlabarere a25b591
CCM-13278: Fix code duplication
simonlabarere 8d97642
CCM-13278: Fix TF
simonlabarere 57cb594
CCM-13278: Fix TF
simonlabarere 2117067
CCM-13278: Updated TF config
simonlabarere c8dfd68
CCM-13278: Remove MESH cert expiry metric from MESH Acknowledge
simonlabarere c2008de
CCM-13278: Address review comments
simonlabarere 98792ed
CCM-13278: Create Python Utility library
simonlabarere b4edb2b
CCM-13278: Improve test coverage
simonlabarere 1148cb7
CCM-13278: Improve test coverage
simonlabarere 2b0fb1d
Merge branch 'main' into feature/CCM-13278_mesh_acknowledge
simonlabarere 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
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
10 changes: 10 additions & 0 deletions
10
...astructure/terraform/components/dl/lambda_event_source_mapping_mesh_acknowledge_lambda.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" "sqs_mesh_acknowledge_lambda" { | ||
| event_source_arn = module.sqs_mesh_acknowledge.sqs_queue_arn | ||
| function_name = module.mesh_acknowledge.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
151 changes: 151 additions & 0 deletions
151
infrastructure/terraform/components/dl/module_lambda_mesh_acknowledge.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,151 @@ | ||
| module "mesh_acknowledge" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip" | ||
|
|
||
| function_name = "mesh-acknowledge" | ||
| description = "A lambda function for acknowledging MESH messages" | ||
| 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_acknowledge_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-acknowledge/target/dist" | ||
| function_include_common = true | ||
| function_module_name = "mesh_acknowledge" | ||
| handler_function_name = "handler.handler" | ||
| runtime = "python3.14" | ||
| memory = 128 | ||
| timeout = 5 | ||
| log_level = var.log_level | ||
|
|
||
| force_lambda_code_deploy = var.force_lambda_code_deploy | ||
| enable_lambda_insights = false | ||
|
|
||
| log_destination_arn = local.log_destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| lambda_env_vars = { | ||
| CERTIFICATE_EXPIRY_METRIC_NAME = "mesh-acknowledge-client-certificate-near-expiry" | ||
| CERTIFICATE_EXPIRY_METRIC_NAMESPACE = "dl-mesh-acknowledge" | ||
| DLQ_URL = module.sqs_mesh_acknowledge.sqs_dlq_url | ||
| ENVIRONMENT = var.environment | ||
| EVENT_PUBLISHER_DLQ_URL = module.sqs_event_publisher_errors.sqs_queue_url | ||
| EVENT_PUBLISHER_EVENT_BUS_ARN = aws_cloudwatch_event_bus.main.arn | ||
| MOCK_MESH_BUCKET = module.s3bucket_non_pii_data.bucket | ||
| SSM_PREFIX = "${local.ssm_prefix}" | ||
| USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false" | ||
| } | ||
|
|
||
| } | ||
|
|
||
| data "aws_iam_policy_document" "mesh_acknowledge_lambda" { | ||
| statement { | ||
| sid = "KMSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.kms.key_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SQSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:ReceiveMessage", | ||
| "sqs:DeleteMessage", | ||
| "sqs:GetQueueAttributes", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_mesh_acknowledge.sqs_queue_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SQSDLQPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:SendMessage", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_mesh_acknowledge.sqs_dlq_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, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SSMPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "ssm:GetParameter", | ||
| "ssm:GetParametersByPath", | ||
| ] | ||
|
|
||
| resources = [ | ||
| "arn:aws:ssm:${var.region}:${var.aws_account_id}:parameter${local.ssm_prefix}/*" | ||
| ] | ||
| } | ||
|
|
||
| # Grant S3 PutObject permissions for the mock-mesh directory only when the mock is enabled | ||
| dynamic "statement" { | ||
| for_each = var.enable_mock_mesh ? [1] : [] | ||
| content { | ||
| sid = "MockMeshPutObject" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:PutObject", | ||
| ] | ||
|
|
||
| resources = [ | ||
| "${module.s3bucket_non_pii_data.arn}/mock-mesh/*" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
58 changes: 58 additions & 0 deletions
58
infrastructure/terraform/components/dl/module_s3bucket_non_pii_data.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,58 @@ | ||
| module "s3bucket_non_pii_data" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-s3bucket.zip" | ||
|
|
||
| name = "non-pii-data" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| region = var.region | ||
| project = var.project | ||
| environment = var.environment | ||
| component = local.component | ||
|
|
||
| kms_key_arn = module.kms.key_arn | ||
|
|
||
| policy_documents = [data.aws_iam_policy_document.s3bucket_non_pii_data.json] | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "s3bucket_non_pii_data" { | ||
| statement { | ||
| sid = "AllowManagedAccountsToList" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:ListBucket", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.s3bucket_non_pii_data.arn, | ||
| ] | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [ | ||
| "arn:aws:iam::${var.aws_account_id}:root" | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowManagedAccountsToGet" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "s3:GetObject", | ||
| "s3:PutObject", | ||
| ] | ||
|
|
||
| resources = [ | ||
| "${module.s3bucket_non_pii_data.arn}/*", | ||
| ] | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [ | ||
| "arn:aws:iam::${var.aws_account_id}:root" | ||
| ] | ||
| } | ||
| } | ||
| } |
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.