Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c3c803a
NRL-1479 update firehose buffer time for quicker testing
jackleary Jun 9, 2025
aca8513
NRL-1479 update logging set up
jackleary Jun 9, 2025
67152e7
NRL-1479 Update logging
jackleary Jun 10, 2025
da6b10d
NRL-1479 Update iam role to allow notebooks to run
jackleary Jun 11, 2025
2c6322c
NRL-1479 Update logging and lower all columns before writing to parquet
jackleary Jun 11, 2025
cfa08a5
[NRL-1386] Add reporting infra to all envs
mattdean3-nhs Jun 11, 2025
7a34959
NRL-1479 Add views as saved queries
jackleary Jun 12, 2025
9cf8f54
NRL-1479 Add athena views to deployment
jackleary Jun 13, 2025
53acc81
[NRL-1386] Rename ec2 module, add toggle for powerbi gw deploy.
mattdean3-nhs Jun 13, 2025
e72cc3a
Merge remote-tracking branch 'origin/feature/jale13-NRL-1479-temp-cha…
mattdean3-nhs Jun 13, 2025
8cdf238
[NRL-1386] Revert unwanted firehose buffering change
mattdean3-nhs Jun 13, 2025
910dd30
[NRL-1386] WIP Fixup powerbi gw TF prov issues
mattdean3-nhs Jun 16, 2025
0e8116a
[NRL-1386] Add missing glue_database to test+prod. Fix TF apply state…
mattdean3-nhs Jun 16, 2025
b25f569
[NRL-1386] Fix glue source bucket lifecycle auto-deletes
mattdean3-nhs Jun 16, 2025
950d036
[NRL-1386] Add var to enable/disable all reporting services per env a…
mattdean3-nhs Jun 18, 2025
e73a0c6
[NRL-1386] Don't provision infra firehose streams for ephem envs
mattdean3-nhs Jun 18, 2025
8ef6f0a
[NRL-1386] Enable reporting infra in dev by default
mattdean3-nhs Jun 18, 2025
b56610a
[NRL-1386] Fix TF bug in infra with firehose__processor
mattdean3-nhs Jun 19, 2025
f75a740
[NRL-1386] Switch lambda subscriptions to a named map
mattdean3-nhs Jun 20, 2025
a5dc5be
[NRL-1386] Re-worded flag TF var descr. Removed unused powerbi-gw mod…
mattdean3-nhs Jun 20, 2025
5ef6668
Merge remote-tracking branch 'origin/develop' into feature/made14-NRL…
mattdean3-nhs Jun 24, 2025
15263c7
[NRL-1386] Fix SNS notifications for backup source
mattdean3-nhs Jun 24, 2025
43b2e4e
[NRL-1386] Remove env-specific reporting infra from account-wide
mattdean3-nhs Jun 24, 2025
73bae58
NRL-1386 Increase EC2 storage to allow standard gw set up
jackleary Jun 24, 2025
157a145
NRL-1386 Remove unused col in views
jackleary Jun 24, 2025
2dad8a1
NRL-1386 group small files together
jackleary Jun 25, 2025
3f1315d
NRL-1386 Update group size to 128mb
jackleary Jun 26, 2025
37005d4
NRL-1386 Update readme with updated instructions for standard gw inst…
jackleary Jun 26, 2025
02eff29
[NRL-1386] Make lambda subscription filters unique per firehose stream
mattdean3-nhs Jun 27, 2025
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
8 changes: 5 additions & 3 deletions terraform/account-wide-infrastructure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ If deploying the EC2 set up to a new environment, these steps need to be followe
aws ssm start-session --target <AMI> --document-name AWS-StartPortForwardingSession --parameters "localPortNumber=13389,portNumber=3389"
```

2. Install Athena ODBC driver and Power BI personal on premises gateway
3. Configure ODBC driver to connect to relevant Athena instance and log in to the gateway using NHS email
4. Log into power bi and test the refresh on the relevant data sources
2. Install Athena ODBC driver and Power BI standard on premises gateway
3. Configure ODBC driver to connect to relevant Athena instance
4. Log in to the gateway using NHS email, name the cluster to nhsd-nrlf-{env}--reporting-gw
5. Log on to power bi, navigate to Manage Connections and Gateways in settings and set up Athena connector with authentication method: Anonymous and privacy level: Private
6. Set dataset to point to this gateway, define schedule as needed

## Tear down account wide resources

Expand Down
2 changes: 2 additions & 0 deletions terraform/account-wide-infrastructure/dev/athena.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module "dev-athena" {
count = var.enable_reporting ? 1 : 0
source = "../modules/athena"
name_prefix = "nhsd-nrlf--dev"
target_bucket_name = module.dev-glue.target_bucket_name
glue_database = module.dev-glue.glue_database
}
20 changes: 11 additions & 9 deletions terraform/account-wide-infrastructure/dev/ec2.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module "vpc" {
count = var.enable_reporting && var.enable_powerbi_auto_push ? 1 : 0
source = "../modules/vpc"
vpc_cidr_block = var.vpc_cidr_block
enable_dns_hostnames = var.enable_dns_hostnames
Expand All @@ -8,16 +9,17 @@ module "vpc" {
name_prefix = "nhsd-nrlf--dev"
}

module "powerbi_gw_instance_v2" {
source = "../modules/ec2"
use_custom_ami = true
instance_type = var.instance_type
name_prefix = "nhsd-nrlf--dev-powerbi-gw-v2"
module "powerbi_gw_instance" {
count = var.enable_reporting && var.enable_powerbi_auto_push ? 1 : 0
source = "../modules/powerbi-gw-ec2"
use_custom_ami = var.use_powerbi_gw_custom_ami
instance_type = var.powerbi_gw_instance_type
name_prefix = "nhsd-nrlf--dev-powerbi-gw"
target_bucket_arn = module.dev-glue.target_bucket_arn
glue_kms_key_arn = module.dev-glue.aws_kms_key_arn
athena_kms_key_arn = module.dev-athena.kms_key_arn
athena_bucket_arn = module.dev-athena.bucket_arn
athena_kms_key_arn = module.dev-athena[0].kms_key_arn
athena_bucket_arn = module.dev-athena[0].bucket_arn

subnet_id = module.vpc.private_subnet_id
security_groups = [module.vpc.powerbi_gw_security_group_id]
subnet_id = module.vpc[0].private_subnet_id
security_groups = [module.vpc[0].powerbi_gw_security_group_id]
}
1 change: 1 addition & 0 deletions terraform/account-wide-infrastructure/dev/glue.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module "dev-glue" {
is_enabled = var.enable_reporting
source = "../modules/glue"
name_prefix = "nhsd-nrlf--dev"
python_version = 3
Expand Down
22 changes: 17 additions & 5 deletions terraform/account-wide-infrastructure/dev/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ variable "devsandbox_api_domain_name" {
default = "dev-sandbox.api.record-locator.dev.national.nhs.uk"
}

variable "enable_reporting" {
type = bool
description = "Enable account-wide reporting processes in the dev account"
default = true
}

variable "aws_azs" {
type = string
description = "AWS Availability Zones"
Expand Down Expand Up @@ -44,14 +50,20 @@ variable "vpc_private_subnets_cidr_block" {
default = "10.0.1.0/24"
}

variable "instance_type" {
variable "enable_powerbi_auto_push" {
type = bool
description = "Enable automatic pushing of info into PowerBI"
default = true
}

variable "powerbi_gw_instance_type" {
type = string
description = "Type for EC2 Instance"
description = "Type for PowerBI GW EC2 Instance"
default = "t2.micro"
}

variable "use_custom_ami" {
variable "use_powerbi_gw_custom_ami" {
type = bool
description = "Use custom image"
default = false
description = "Use custom image for PowerBI GW instance"
default = true
}
14 changes: 14 additions & 0 deletions terraform/account-wide-infrastructure/modules/athena/athena.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ resource "aws_athena_workgroup" "athena" {
}

}

resource "aws_athena_named_query" "rep_consumer" {
name = "rep_consumer"
workgroup = aws_athena_workgroup.athena.id
database = var.glue_database
query = file("${path.module}/sql/rep_consumer.sql")
}

resource "aws_athena_named_query" "rep_producer" {
name = "rep_producer"
workgroup = aws_athena_workgroup.athena.id
database = var.glue_database
query = file("${path.module}/sql/rep_producer.sql")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
CREATE OR REPLACE VIEW "rep_consumer" AS
WITH
cc AS (
SELECT
time
, event_timestamp
, date
, host
, event_log_reference
, event_level
, event_location
, event_message
, event_service
, event_function_request_id
, event_correlation_id
, event_xray_trace_id
, event_pointer_types
, COALESCE("event_headers_nhsd-end-user-organisation-ods", event_metadata_ods_code) user_ods
FROM
consumer_countdocumentreference
)
, cr AS (
SELECT
time
, event_timestamp
, date
, host
, event_log_reference
, event_level
, event_location
, event_message
, event_service
, event_function_request_id
, event_correlation_id
, event_xray_trace_id
, event_pointer_types
, COALESCE("event_headers_nhsd-end-user-organisation-ods", event_metadata_ods_code) user_ods
FROM
consumer_readdocumentreference
)
, cs AS (
SELECT
time
, event_timestamp
, date
, host
, event_log_reference
, event_level
, event_location
, event_message
, event_service
, event_function_request_id
, event_correlation_id
, event_xray_trace_id
, event_pointer_types
, COALESCE("event_headers_nhsd-end-user-organisation-ods", event_metadata_ods_code) user_ods
FROM
consumer_searchdocumentreference
)
, csp AS (
SELECT
time
, event_timestamp
, date
, host
, event_log_reference
, event_level
, event_location
, event_message
, event_service
, event_function_request_id
, event_correlation_id
, event_xray_trace_id
, event_pointer_types
, COALESCE("event_headers_nhsd-end-user-organisation-ods", event_metadata_ods_code) user_ods
FROM
consumer_searchpostdocumentreference
)
, base AS (
SELECT *
FROM
cc
UNION SELECT *
FROM
cr
UNION SELECT *
FROM
cs
UNION SELECT *
FROM
csp
)
, ods_codes AS (
SELECT DISTINCT
user_ods
, event_xray_trace_id
FROM
base
WHERE (user_ods IS NOT NULL)
)
SELECT
time
, event_timestamp
, date
, host
, event_log_reference
, event_level
, event_location
, event_message
, event_service
, event_function_request_id
, b.event_correlation_id
, b.event_xray_trace_id
, event_pointer_types
, oc.user_ods
FROM
(base b
LEFT JOIN ods_codes oc ON (b.event_xray_trace_id = oc.event_xray_trace_id))
Loading
Loading