Skip to content
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

PRMP-1123 #206

Merged
merged 10 commits into from
Dec 2, 2024
Merged
35 changes: 35 additions & 0 deletions infrastructure/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,34 @@ module "ndr-ecs-fargate-ods-update" {
{
"name" : "PDS_FHIR_IS_STUBBED",
"value" : tostring(local.is_sandbox)
},
{
"name" : "LLOYD_GEORGE_BUCKET_NAME",
"value" : "${terraform.workspace}-${var.lloyd_george_bucket_name}"
},
{
"name" : "LLOYD_GEORGE_DYNAMODB_NAME",
"value" : "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
},
{
"name" : "DOCUMENT_STORE_BUCKET_NAME",
"value" : "${terraform.workspace}-${var.docstore_bucket_name}"
},
{
"name" : "DOCUMENT_STORE_DYNAMODB_NAME",
"value" : "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
},
{
"name" : "STATISTICAL_REPORTS_BUCKET",
"value" : "${terraform.workspace}-${var.statistical_reports_bucket_name}"
},
{
"name" : "STATISTICS_TABLE",
"value" : "${terraform.workspace}_${var.statistics_dynamodb_table_name}"
},
{
"name" : "WORKSPACE",
"value" : terraform.workspace
}
]
ecs_container_definition_memory = 512
Expand All @@ -74,6 +102,13 @@ resource "aws_iam_role" "ods_weekly_update_task_role" {
managed_policy_arns = [
module.lloyd_george_reference_dynamodb_table.dynamodb_policy,
aws_iam_policy.ssm_access_policy.arn,
module.statistics_dynamodb_table.dynamodb_policy,
module.statistical-reports-store.s3_object_access_policy,
module.ndr-app-config.app_config_policy_arn,
module.ndr-lloyd-george-store.s3_list_object_policy,
module.ndr-document-store.s3_list_object_policy,
module.document_reference_dynamodb_table.dynamodb_policy,
aws_iam_policy.cloudwatch_log_query_policy.arn
]
assume_role_policy = jsonencode(
{
Expand Down
58 changes: 0 additions & 58 deletions infrastructure/schedules.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,64 +57,6 @@ resource "aws_lambda_permission" "bulk_upload_report_schedule_permission" {
]
}

resource "aws_cloudwatch_event_rule" "data_collection_schedule" {
name = "${terraform.workspace}_data_collection_schedule"
description = "Schedule for Data Collection Lambda"
schedule_expression = "cron(0 20 * * ? *)"
}

resource "aws_cloudwatch_event_target" "data_collection_schedule_event" {
rule = aws_cloudwatch_event_rule.data_collection_schedule.name
target_id = "data_collection_schedule"

arn = module.data-collection-lambda.lambda_arn
depends_on = [
module.data-collection-lambda,
aws_cloudwatch_event_rule.data_collection_schedule
]
}

resource "aws_lambda_permission" "data_collection_schedule_permission" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = module.data-collection-lambda.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.data_collection_schedule.arn
depends_on = [
module.data-collection-lambda,
aws_cloudwatch_event_rule.data_collection_schedule
]
}

resource "aws_cloudwatch_event_rule" "statistical_report_schedule" {
name = "${terraform.workspace}_statistical_report_schedule"
description = "Schedule for Statistical Report Lambda"
schedule_expression = "cron(0 8 ? * 2 *)"
}

resource "aws_cloudwatch_event_target" "statistical_report_schedule_event" {
rule = aws_cloudwatch_event_rule.statistical_report_schedule.name
target_id = "statistical_report_schedule"

arn = module.statistical-report-lambda.lambda_arn
depends_on = [
module.statistical-report-lambda,
aws_cloudwatch_event_rule.statistical_report_schedule
]
}

resource "aws_lambda_permission" "statistical_report_schedule_permission" {
statement_id = "AllowExecutionFromCloudWatch"
action = "lambda:InvokeFunction"
function_name = module.statistical-report-lambda.function_name
principal = "events.amazonaws.com"
source_arn = aws_cloudwatch_event_rule.statistical_report_schedule.arn
depends_on = [
module.statistical-report-lambda,
aws_cloudwatch_event_rule.statistical_report_schedule
]
}

resource "aws_scheduler_schedule" "ods_weekly_update_ecs" {
count = local.is_sandbox ? 0 : 1
name_prefix = "${terraform.workspace}_ods_weekly_update_ecs"
Expand Down
Loading