Skip to content

Commit e3974e1

Browse files
Merge branch 'main' into PRM-562
2 parents 4a6705d + b289905 commit e3974e1

File tree

7 files changed

+71
-2
lines changed

7 files changed

+71
-2
lines changed

.github/workflows/cron-tear-down-sandbox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'Z-CRON: Tear down - Sandboxes'
22

33
on:
44
schedule:
5-
- cron: 59 17 * * 1-5 # utc time
5+
- cron: 59 18-21 * * 1-5 # utc time
66

77
permissions:
88
pull-requests: write

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ This repository is used to build the infrastructure the NDR. That is it's sole p
77
- [Terraform](https://developer.hashicorp.com/terraform/install)
88
- [Terraform docs](https://github.com/terraform-docs/terraform-docs)
99

10+
To install terraform-docs on WSL use the following commands (e.g. for v0.20.0):
11+
```
12+
curl -sSLo ./terraform-docs.tar.gz https://terraform-docs.io/dl/v0.20.0/terraform-docs-v0.20.0-$(uname)-amd64.tar.gz
13+
tar -xzf terraform-docs.tar.gz
14+
chmod +x terraform-docs
15+
sudo mv terraform-docs /usr/local/bin/terraform-docs
16+
rm terraform-docs.tar.gz
17+
```
18+
1019
## Installation
1120

1221
### pre-commit hook

infrastructure/api.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ resource "aws_api_gateway_stage" "ndr_api" {
9595
depends_on = [
9696
aws_cloudwatch_log_group.api_gateway_stage
9797
]
98+
99+
lifecycle {
100+
create_before_destroy = true
101+
}
98102
}
99103

100104
resource "aws_cloudwatch_log_group" "api_gateway_stage" {

infrastructure/api_mtls.tf

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ resource "aws_api_gateway_base_path_mapping" "api_mapping_mtls" {
3333
stage_name = var.environment
3434
domain_name = aws_api_gateway_domain_name.custom_api_domain_mtls.domain_name
3535

36-
depends_on = [aws_api_gateway_deployment.ndr_api_deploy_mtls]
36+
depends_on = [
37+
aws_api_gateway_deployment.ndr_api_deploy_mtls,
38+
aws_api_gateway_rest_api.ndr_doc_store_api_mtls
39+
]
3740
}
3841

3942
resource "aws_api_gateway_deployment" "ndr_api_deploy_mtls" {
@@ -67,6 +70,12 @@ resource "aws_api_gateway_stage" "ndr_api_mtls" {
6770
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api_mtls.id
6871
stage_name = var.environment
6972
xray_tracing_enabled = var.enable_xray_tracing
73+
74+
lifecycle {
75+
create_before_destroy = true
76+
}
77+
78+
depends_on = [aws_cloudwatch_log_group.mtls_api_gateway_stage]
7079
}
7180

7281
resource "aws_cloudwatch_log_group" "mtls_api_gateway_stage" {

infrastructure/lambda-document-upload-check.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ resource "aws_s3_bucket_notification" "document_upload_check_lambda_trigger" {
6060
events = ["s3:ObjectCreated:*"]
6161
filter_prefix = "user_upload"
6262
}
63+
64+
lambda_function {
65+
lambda_function_arn = module.document_upload_check_lambda.lambda_arn
66+
events = ["s3:ObjectCreated:*"]
67+
filter_prefix = "fhir_upload"
68+
}
6369
}
6470

6571
resource "aws_lambda_permission" "document_upload_check_lambda" {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module "migration-dynamodb-lambda" {
2+
source = "./modules/lambda"
3+
name = "MigrationDynamoDB"
4+
handler = "handlers.migration_dynamodb_handler.lambda_handler"
5+
6+
iam_role_policy_documents = [
7+
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
8+
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
9+
module.bulk_upload_report_dynamodb_table.dynamodb_read_policy_document,
10+
module.ndr-bulk-staging-store.s3_read_policy_document,
11+
module.ndr-lloyd-george-store.s3_read_policy_document,
12+
aws_iam_policy.ssm_access_policy.policy,
13+
module.ndr-app-config.app_config_policy
14+
]
15+
16+
kms_deletion_window = var.kms_deletion_window
17+
rest_api_id = null
18+
api_execution_arn = null
19+
is_gateway_integration_needed = false
20+
is_invoked_from_gateway = false
21+
22+
lambda_environment_variables = {
23+
WORKSPACE = terraform.workspace
24+
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
25+
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
26+
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
27+
}
28+
29+
lambda_timeout = 900
30+
memory_size = 1024
31+
reserved_concurrent_executions = 200
32+
33+
depends_on = [
34+
module.lloyd_george_reference_dynamodb_table,
35+
module.bulk_upload_report_dynamodb_table,
36+
module.ndr-app-config,
37+
aws_iam_policy.ssm_access_policy,
38+
]
39+
}

scripts/cleanup_sandboxes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import time
12
import boto3, os, requests, sys
23

34
from botocore.exceptions import ClientError
@@ -62,3 +63,4 @@ def get_workspaces() -> list[str]:
6263
for workspace in workspaces:
6364
if workspace not in excluded:
6465
trigger_delete_workflow(token=gh_pat, sandbox=workspace)
66+
time.sleep(300) # Wait 5 min between executions to avoid an AWS concurrency issue.

0 commit comments

Comments
 (0)