Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/actions/acceptance-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,24 @@ runs:
TEST_TYPE: ${{ inputs.testType }}
ENVIRONMENT: ${{ inputs.targetEnvironment }}
PLAYWRIGHT_SHARD: ${{ inputs.shard }}
- name: Extract shard index
id: extract_shard
shell: bash
env:
SHARD: ${{ inputs.shard }}
run: |
shard="${SHARD:-}"

if [ -z "$shard" ]; then
shard_index="all"
else
shard_index="${shard%%/*}"
fi

echo "shard_index=$shard_index" >> "$GITHUB_OUTPUT"
- name: Archive integration test results
if: ${{ inputs.testType == 'integration' }}
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: Integration test report
name: Integration test report - ${{ steps.extract_shard.outputs.shard_index }}
path: "tests/playwright/playwright-report"
1 change: 1 addition & 0 deletions infrastructure/terraform/components/dl/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ locals {
unscanned_files_bucket = local.acct.additional_s3_buckets["digital-letters_unscanned-files"]["id"]

bc_restricted_dev_role = try(tolist(data.aws_iam_roles.sso_bc_restricted_dev[0].arns)[0], null)
metrics_namespace_name = "nhs-${var.environment}-${var.component}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module "core_notifier" {
"EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url
"ENVIRONMENT" = var.environment
"NHS_APP_BASE_URL" = var.nhs_app_base_url
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module "file_scanner" {
"UNSCANNED_FILES_PATH_PREFIX" = local.csi
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module "mesh_acknowledge" {
SSM_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
DL_METRICS_NAMESPACE = local.metrics_namespace_name
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ module "mesh_download" {
log_subscription_role_arn = local.acct.log_subscription_role_arn

lambda_env_vars = {
DOWNLOAD_METRIC_NAME = "mesh-download-successful-downloads"
INTERNAL_DUPLICATE_DOWNLOAD_METRIC_NAME = "mesh-internal-duplicate-downloads"
TRUST_DUPLICATE_DOWNLOAD_METRIC_NAME = "mesh-trust-duplicate-downloads"
DOWNLOAD_METRIC_NAMESPACE = "dl-mesh-download"
DOWNLOAD_METRIC_NAME = "dl-mesh-download-successful-downloads"
INTERNAL_DUPLICATE_DOWNLOAD_METRIC_NAME = "dl-mesh-download-internal-duplicate-downloads"
TRUST_DUPLICATE_DOWNLOAD_METRIC_NAME = "dl-mesh-download-trust-duplicate-downloads"
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
PII_BUCKET = module.s3bucket_pii_data.bucket
SSM_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
DL_METRICS_NAMESPACE = local.metrics_namespace_name
}

}
Expand Down
21 changes: 10 additions & 11 deletions infrastructure/terraform/components/dl/module_lambda_mesh_poll.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,16 @@ module "mesh_poll" {
log_subscription_role_arn = local.acct.log_subscription_role_arn

lambda_env_vars = {
CERTIFICATE_EXPIRY_METRIC_NAME = "mesh-poll-client-certificate-near-expiry"
CERTIFICATE_EXPIRY_METRIC_NAMESPACE = "dl-mesh-poll"
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
LAMBDA_TIMEOUT_BUFFER_MILLISECONDS = "60000" # 1 minute, to leave time for mesh-download to acknowledge the message before we run again.
POLLING_METRIC_NAME = "mesh-poll-successful-polls"
POLLING_METRIC_NAMESPACE = "dl-mesh-poll"
SSM_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
CERTIFICATE_EXPIRY_METRIC_NAME = "dl-mesh-poll-client-certificate-near-expiry"
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
LAMBDA_TIMEOUT_BUFFER_MILLISECONDS = "60000" # 1 minute, to leave time for mesh-download to acknowledge the message before we run again.
POLLING_METRIC_NAME = "dl-mesh-poll-successful-polls"
SSM_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
DL_METRICS_NAMESPACE = local.metrics_namespace_name
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module "move_scanned_files" {
"UNSCANNED_FILE_S3_BUCKET_NAME" = local.unscanned_files_bucket
"SAFE_FILE_S3_BUCKET_NAME" = module.s3bucket_file_safe.bucket
"QUARANTINE_FILE_S3_BUCKET_NAME" = module.s3bucket_file_quarantine.bucket
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module "nhsapp_status_handler" {
"TTL_TABLE_NAME" = aws_dynamodb_table.ttl.name
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ module "pdm_poll" {
"EVENT_PUBLISHER_EVENT_BUS_ARN" = aws_cloudwatch_event_bus.main.arn
"EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url
"POLL_MAX_RETRIES" = 10
"ENVIRONMENT" = var.environment
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module "pdm_uploader" {
"APIM_ACCESS_TOKEN_SSM_PARAMETER_NAME" = local.pdm_access_token_ssm_parameter_name
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module "print_analyser" {
lambda_env_vars = {
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "print_sender" {
"EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url
"ENVIRONMENT" = var.environment
"ACCOUNT_TYPE" = var.aws_account_type
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ module "print_status_handler" {
lambda_env_vars = {
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ module "report_event_transformer" {

log_destination_arn = local.log_destination_arn
log_subscription_role_arn = local.acct.log_subscription_role_arn
lambda_env_vars = {
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module "report_generator" {
"REPORTING_BUCKET" = module.s3bucket_reporting.bucket
"REPORT_NAME" = "completed_communications"
"WAIT_FOR_IN_SECONDS" = var.athena_query_polling_time_seconds
"ENVIRONMENT" = var.environment
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module "report_scheduler" {
"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
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ module "report_sender" {
log_subscription_role_arn = local.acct.log_subscription_role_arn

lambda_env_vars = {
REPORT_SENDER_METRIC_NAME = "report-sender-successful-sends"
REPORT_SENDER_METRIC_NAMESPACE = "dl-report-sender"
DLQ_URL = module.sqs_report_sender.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_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
REPORT_SENDER_METRIC_NAME = "dl-report-sender-successful-sends"
DLQ_URL = module.sqs_report_sender.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_MESH_PREFIX = local.ssm_mesh_prefix
SSM_SENDERS_PREFIX = local.ssm_senders_prefix
USE_MESH_MOCK = var.enable_mock_mesh ? "true" : "false"
DL_METRICS_NAMESPACE = local.metrics_namespace_name
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ module "ttl_create" {
"TTL_SHARD_COUNT" = local.ttl_shard_count
"EVENT_PUBLISHER_EVENT_BUS_ARN" = aws_cloudwatch_event_bus.main.arn
"EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ module "ttl_handle_expiry" {
"EVENT_PUBLISHER_EVENT_BUS_ARN" = aws_cloudwatch_event_bus.main.arn
"EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url
"DLQ_URL" = module.sqs_ttl_handle_expiry_errors.sqs_queue_url
"ENVIRONMENT" = var.environment
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ module "ttl_poll" {
log_subscription_role_arn = local.acct.log_subscription_role_arn

lambda_env_vars = {
"TTL_TABLE_NAME" = aws_dynamodb_table.ttl.name
"CONCURRENCY" = 60
"MAX_PROCESS_SECONDS" = 300
"TTL_SHARD_COUNT" = local.ttl_shard_count
"TTL_TABLE_NAME" = aws_dynamodb_table.ttl.name
"CONCURRENCY" = 60
"MAX_PROCESS_SECONDS" = 300
"TTL_SHARD_COUNT" = local.ttl_shard_count
"ENVIRONMENT" = var.environment
"DL_METRICS_NAMESPACE" = local.metrics_namespace_name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jest.mock('utils', () => ({
debug: jest.fn(),
},
EventPublisher: jest.fn(),
MetricHandler: jest.fn(),
eventBridgeClient: {},
sqsClient: {},
}));
Expand All @@ -42,6 +43,7 @@ describe('createContainer', () => {
apimBaseUrl: 'https://api.test.nhs.uk',
environment: 'test',
nhsAppBaseUrl: 'https://example.com',
dlMetricsNamespace: 'test-namespace',
};

const mockSenderManagement = mock<ISenderManagement>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('loadConfig', () => {
apimBaseUrl: 'https://api.test.nhs.uk',
nhsAppBaseUrl: 'https://example.com',
environment: 'test',
dlMetricsNamespace: 'test-namespace',
};

mockGetValue
Expand All @@ -32,12 +33,13 @@ describe('loadConfig', () => {
.mockReturnValueOnce(mockConfig.apimAccessTokenSsmParameterName)
.mockReturnValueOnce(mockConfig.apimBaseUrl)
.mockReturnValueOnce(mockConfig.nhsAppBaseUrl)
.mockReturnValueOnce(mockConfig.environment);
.mockReturnValueOnce(mockConfig.environment)
.mockReturnValueOnce(mockConfig.dlMetricsNamespace);

const result = loadConfig();

expect(result).toEqual(mockConfig);
expect(mockGetValue).toHaveBeenCalledTimes(6);
expect(mockGetValue).toHaveBeenCalledTimes(7);
expect(mockGetValue).toHaveBeenNthCalledWith(
1,
'EVENT_PUBLISHER_EVENT_BUS_ARN',
Expand All @@ -50,6 +52,7 @@ describe('loadConfig', () => {
expect(mockGetValue).toHaveBeenNthCalledWith(4, 'APIM_BASE_URL');
expect(mockGetValue).toHaveBeenNthCalledWith(5, 'NHS_APP_BASE_URL');
expect(mockGetValue).toHaveBeenNthCalledWith(6, 'ENVIRONMENT');
expect(mockGetValue).toHaveBeenNthCalledWith(7, 'DL_METRICS_NAMESPACE');
});

it('returns config with correct types', () => {
Expand All @@ -59,7 +62,8 @@ describe('loadConfig', () => {
.mockReturnValueOnce('/param')
.mockReturnValueOnce('https://api')
.mockReturnValueOnce('https://example.com')
.mockReturnValueOnce('prod');
.mockReturnValueOnce('prod')
.mockReturnValueOnce('test-namespace');

const result: NotifySendMessageConfig = loadConfig();

Expand All @@ -69,5 +73,6 @@ describe('loadConfig', () => {
expect(typeof result.apimBaseUrl).toBe('string');
expect(typeof result.nhsAppBaseUrl).toBe('string');
expect(typeof result.environment).toBe('string');
expect(typeof result.dlMetricsNamespace).toBe('string');
});
});
14 changes: 13 additions & 1 deletion lambdas/core-notifier-lambda/src/container.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
EventPublisher,
MetricHandler,
ParameterStoreCache,
createGetApimAccessToken,
eventBridgeClient,
Expand Down Expand Up @@ -41,14 +42,25 @@ export async function createContainer(): Promise<SqsHandlerDependencies> {
logger,
});

const { eventPublisherDlqUrl, eventPublisherEventBusArn } = config;
const {
dlMetricsNamespace,
eventPublisherDlqUrl,
eventPublisherEventBusArn,
} = config;
const metricHandler = new MetricHandler(dlMetricsNamespace, [
{
Name: 'Environment',
Value: config.environment,
},
]);

const eventPublisher = new EventPublisher({
eventBusArn: eventPublisherEventBusArn,
dlqUrl: eventPublisherDlqUrl,
logger,
sqsClient,
eventBridgeClient,
metricHandler,
});

const coreRequestMapper = new CoreRequestMapper(config.nhsAppBaseUrl);
Expand Down
2 changes: 2 additions & 0 deletions lambdas/core-notifier-lambda/src/infra/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type NotifySendMessageConfig = {
apimBaseUrl: string;
nhsAppBaseUrl: string;
environment: string;
dlMetricsNamespace: string;
};

export function loadConfig(): NotifySendMessageConfig {
Expand All @@ -23,5 +24,6 @@ export function loadConfig(): NotifySendMessageConfig {
apimBaseUrl: defaultConfigReader.getValue('APIM_BASE_URL'),
nhsAppBaseUrl: defaultConfigReader.getValue('NHS_APP_BASE_URL'),
environment: defaultConfigReader.getValue('ENVIRONMENT'),
dlMetricsNamespace: defaultConfigReader.getValue('DL_METRICS_NAMESPACE'),
};
}
4 changes: 4 additions & 0 deletions lambdas/file-scanner-lambda/src/__tests__/container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ describe('createContainer', () => {
it('should create container with all dependencies', () => {
mockLoadConfig.mockReturnValue({
documentReferenceBucket: 'test-doc-ref-bucket',
environment: 'test',
unscannedFilesBucket: 'test-unscanned-bucket',
unscannedFilesPathPrefix: 'dev',
eventPublisherEventBusArn:
'arn:aws:events:us-east-1:123456789012:event-bus/test',
eventPublisherDlqUrl: 'https://sqs.us-east-1.amazonaws.com/dlq',
dlMetricsNamespace: 'test-namespace',
});

const container = createContainer();
Expand All @@ -33,10 +35,12 @@ describe('createContainer', () => {
it('should call loadConfig to get configuration', () => {
const mockConfig = {
documentReferenceBucket: 'test-bucket',
environment: 'test',
unscannedFilesBucket: 'test-unscanned',
unscannedFilesPathPrefix: 'dev',
eventPublisherEventBusArn: 'arn:test',
eventPublisherDlqUrl: 'url:test',
dlMetricsNamespace: 'test-namespace',
};

mockLoadConfig.mockReturnValue(mockConfig);
Expand Down
Loading
Loading