diff --git a/infrastructure/ecs.tf b/infrastructure/ecs.tf index 662e5111..00ed5a3d 100644 --- a/infrastructure/ecs.tf +++ b/infrastructure/ecs.tf @@ -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 @@ -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( { diff --git a/infrastructure/schedules.tf b/infrastructure/schedules.tf index e7054049..c0bf1d96 100644 --- a/infrastructure/schedules.tf +++ b/infrastructure/schedules.tf @@ -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"