-
Notifications
You must be signed in to change notification settings - Fork 5
CCM-12995 adding event pub infra #240
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
41dcab6
CCM-12995 Adding base eventPub Infra
aidenvaines-cgi 6c7bc30
CCM-12995: Adding sns topic policy for sub
sidnhs 80bd61a
CCM-12995: Adding sns topic policy for sub
sidnhs 7a86f0c
CCM-12995: Adding sns topic policy for sub
sidnhs cbdb33d
CCM-12995 Adding base eventPub Infra
aidenvaines-cgi a643d71
CCM-12995 Adding base eventPub Infra
aidenvaines-cgi 7079a2a
CCM-12312: Fixing typo in kms policy
sidnhs 06b41b1
CCM-12995: Fix comment
sidnhs 142e410
CCM-12995: Update package-lock.json
sidnhs fc20be1
CCM-12995: Update package-lock.json
sidnhs b1c5fa1
CCM-12995: Revert python version back to 3.12
sidnhs 82410cf
Merge branch 'main' into CCM-12995_AddingEventPubInfra
masl2 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
9 changes: 9 additions & 0 deletions
9
infrastructure/terraform/components/api/lambda_event_source_mapping_upsert_letter.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,9 @@ | ||
| resource "aws_lambda_event_source_mapping" "upsert_letter" { | ||
| event_source_arn = module.sqs_letter_updates.sqs_queue_arn | ||
| function_name = module.upsert_letter.function_name | ||
| batch_size = 10 | ||
| maximum_batching_window_in_seconds = 5 | ||
| function_response_types = [ | ||
| "ReportBatchItemFailures" | ||
| ] | ||
| } |
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_authorizer_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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_domain_truststore.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
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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_lambda_get_letter.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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_lambda_get_letter_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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_lambda_get_letters.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
70 changes: 70 additions & 0 deletions
70
infrastructure/terraform/components/api/module_lambda_letter_updates_transformer.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,70 @@ | ||
| module "letter_updates_transformer" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-lambda.zip" | ||
|
|
||
| function_name = "letter-updates-transformer" | ||
| description = "Letter Update Filter/Producer" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.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.letter_updates_transformer_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 = "letter-updates-transformer/dist" | ||
| function_include_common = true | ||
| handler_function_name = "handler" | ||
| runtime = "nodejs22.x" | ||
| memory = 128 | ||
| timeout = 5 | ||
| 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.destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| lambda_env_vars = merge(local.common_lambda_env_vars, { | ||
| EVENTPUB_SNS_TOPIC_ARN = module.eventpub.sns_topic.arn | ||
| }) | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "letter_updates_transformer_lambda" { | ||
| statement { | ||
| sid = "KMSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.kms.key_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowSNSPublish" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sns:Publish" | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.eventpub.sns_topic.arn | ||
| ] | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_lambda_patch_letter.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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_lambda_post_mi.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
84 changes: 84 additions & 0 deletions
84
infrastructure/terraform/components/api/module_lambda_upsert_letter.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,84 @@ | ||
| module "upsert_letter" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-lambda.zip" | ||
|
|
||
| function_name = "upsert-letter" | ||
| description = "Update or Insert the letter data in the letters table" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.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.upsert_letter_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 = "upsert-letter/dist" | ||
| function_include_common = true | ||
| handler_function_name = "handler" | ||
| runtime = "nodejs22.x" | ||
| memory = 128 | ||
| timeout = 5 | ||
| 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.destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| lambda_env_vars = merge(local.common_lambda_env_vars, {}) | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "upsert_letter_lambda" { | ||
| statement { | ||
| sid = "KMSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.kms.key_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowDynamoDBWrite" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "dynamodb:PutItem" | ||
| ] | ||
|
|
||
| resources = [ | ||
| aws_dynamodb_table.letters.arn, | ||
| "${aws_dynamodb_table.letters.arn}/index/supplierStatus-index" | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "AllowSQSRead" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:ReceiveMessage", | ||
| "sqs:DeleteMessage", | ||
| "sqs:GetQueueAttributes" | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_letter_updates.sqs_queue_arn | ||
| ] | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/api/module_logging_bucket.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
16 changes: 16 additions & 0 deletions
16
infrastructure/terraform/components/api/module_sqs_letter_updates.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,16 @@ | ||
| module "sqs_letter_updates" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-sqs.zip" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| name = "letter-updates" | ||
|
|
||
| sqs_kms_key_arn = module.kms.key_arn | ||
|
|
||
| visibility_timeout_seconds = 60 | ||
|
|
||
| create_dlq = true | ||
| } |
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
28 changes: 28 additions & 0 deletions
28
infrastructure/terraform/components/api/modules_eventpub.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,28 @@ | ||
| module "eventpub" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.26/terraform-eventpub.zip" | ||
|
|
||
| name = "eventpub" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| default_tags = local.default_tags | ||
|
|
||
| kms_key_arn = module.kms.key_arn | ||
| log_retention_in_days = var.log_retention_in_days | ||
| log_level = "INFO" | ||
|
|
||
| event_cache_buffer_interval = 500 | ||
| enable_sns_delivery_logging = true | ||
| sns_success_logging_sample_percent = 0 | ||
|
|
||
| event_cache_expiry_days = 30 | ||
| enable_event_cache = true | ||
|
|
||
| data_plane_bus_arn = var.eventpub_data_plane_bus_arn | ||
| control_plane_bus_arn = var.eventpub_control_plane_bus_arn | ||
| } |
26 changes: 26 additions & 0 deletions
26
infrastructure/terraform/components/api/modules_eventsub.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,26 @@ | ||
| module "eventsub" { | ||
| source = "../../modules/eventsub" | ||
|
|
||
| name = "eventsub" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| default_tags = local.default_tags | ||
|
|
||
| kms_key_arn = module.kms.key_arn | ||
| log_retention_in_days = var.log_retention_in_days | ||
| log_level = "INFO" | ||
|
|
||
| event_cache_buffer_interval = 500 | ||
| enable_sns_delivery_logging = true | ||
| sns_success_logging_sample_percent = 0 | ||
|
|
||
| event_cache_expiry_days = 30 | ||
| enable_event_cache = true | ||
| shared_infra_account_id = var.shared_infra_account_id | ||
| } |
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
5 changes: 5 additions & 0 deletions
5
...astructure/terraform/components/api/sns_topic_subscription_eventsub_sqs_letter_updates.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,5 @@ | ||
| resource "aws_sns_topic_subscription" "eventsub_sqs_letter_updates" { | ||
| topic_arn = module.eventsub.sns_topic.arn | ||
| protocol = "sqs" | ||
| endpoint = module.sqs_letter_updates.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.