diff --git a/terraform/modules/services/forecast_generic/README.md b/terraform/modules/services/forecast_generic/README.md deleted file mode 100644 index 7a03c01f..00000000 --- a/terraform/modules/services/forecast_generic/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Modules/Services/Forecast - -This module currently makes -- AWS task definition -- IAM role to setup application -- IAM role for running task -- temp: scheduled aws task, and iam roles diff --git a/terraform/modules/services/forecast_generic/cloudwatch.tf b/terraform/modules/services/forecast_generic/cloudwatch.tf deleted file mode 100644 index bedb3f32..00000000 --- a/terraform/modules/services/forecast_generic/cloudwatch.tf +++ /dev/null @@ -1,12 +0,0 @@ -# set up cloudwatch log group - -resource "aws_cloudwatch_log_group" "predictor" { - name = local.log-group-name - - retention_in_days = 7 - - tags = { - Environment = var.environment - Application = var.app-name - } -} diff --git a/terraform/modules/services/forecast_generic/ecs.tf b/terraform/modules/services/forecast_generic/ecs.tf deleted file mode 100644 index 76f52bd7..00000000 --- a/terraform/modules/services/forecast_generic/ecs.tf +++ /dev/null @@ -1,71 +0,0 @@ -# define aws ecs task definition -# needs access to the internet - -resource "aws_ecs_task_definition" "ecs-task-definition" { - family = var.app-name - requires_compatibilities = ["FARGATE"] - network_mode = "awsvpc" - - tags = { - name = "${var.app-name}-forecaster" - type = "ecs" - } - - # specific values are needed - - # https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html - cpu = var.ecs_config.cpu - memory = var.ecs_config.memory_mb - - task_role_arn = aws_iam_role.app-role.arn - execution_role_arn = var.ecs-task_execution_role_arn - container_definitions = jsonencode([ - { - name = "forecast" - image = "${var.ecs_config.docker_image}:${var.ecs_config.docker_version}" - # cpu = 128 - # memory = 128 - essential = true - - environment : [ - {"name": "LOGLEVEL", "value" : var.loglevel}, - {"name": "NWP_ZARR_PATH", "value":"s3://${var.s3_nwp_bucket.bucket_id}/${var.s3_nwp_bucket.datadir}/latest.zarr"}, - {"name": "NWP_UKV_ZARR_PATH", "value":"s3://${var.s3_nwp_bucket.bucket_id}/${var.s3_nwp_bucket.datadir}/latest.zarr"}, - {"name": "NWP_ECMWF_ZARR_PATH", "value":"s3://${var.s3_nwp_bucket.bucket_id}/ecmwf/data/latest.zarr"}, - {"name": "NWP_GFS_ZARR_PATH", "value":"s3://${var.s3_nwp_bucket.bucket_id}/gfs/data/latest.zarr"}, - {"name": "NWP_MO_GLOBAL_ZARR_PATH", "value": "s3://${var.s3_nwp_bucket.bucket_id}/metoffice/data/latest.zarr"}, - {"name": "SATELLITE_ZARR_PATH", "value":"s3://${var.s3_satellite_bucket.bucket_id}/${var.s3_satellite_bucket.datadir}/latest.zarr.zip"}, - {"name": "ML_MODEL_PATH", "value": "s3://${var.s3_ml_bucket.bucket_id}/"}, - {"name": "ML_MODEL_BUCKET", "value": var.s3_ml_bucket.bucket_id}, - {"name": "ENVIRONMENT", "value": var.environment}, - {"name": "OCF_ENVIRONMENT", "value": var.environment}, - {"name": "USE_ADJUSTER", "value": var.use_adjuster}, - {"name": "SAVE_GSP_SUM", "value": var.pvnet_gsp_sum}, - {"name": "ESMFMKFILE", "value": "/opt/conda/lib/esmf.mk"}, - {"name": "SENTRY_DSN", "value": var.sentry_dsn}, - {"name": "RUN_EXTRA_MODELS", "value": var.run_extra_models}, - {"name": "DAY_AHEAD_MODEL", "value": var.day_ahead_model}, - {"name": "USE_OCF_DATA_SAMPLER", "value": var.use_data_sample}, - ] - - secrets : [ - { - "name" : "OCF_PV_DB_URL", - "valueFrom" : "${var.rds_config.database_secret_arn}:url::", - }, - { - "name": "DB_URL", - "valueFrom": "${var.rds_config.database_secret_arn}:url::", - }, - ] - - logConfiguration : { - "logDriver" : "awslogs", - "options" : { - "awslogs-group" : local.log-group-name, - "awslogs-region" : var.region, - "awslogs-stream-prefix" : "streaming" - } - } - } - ]) -} diff --git a/terraform/modules/services/forecast_generic/iam.tf b/terraform/modules/services/forecast_generic/iam.tf deleted file mode 100644 index 3bb2674b..00000000 --- a/terraform/modules/services/forecast_generic/iam.tf +++ /dev/null @@ -1,34 +0,0 @@ -# Define the IAM task Instance role, used to run the task - -data "aws_iam_policy_document" "ec2-instance-assume-role-policy" { - statement { - actions = ["sts:AssumeRole"] - - principals { - type = "Service" - identifiers = ["ecs-tasks.amazonaws.com"] - } - } -} - -resource "aws_iam_role" "app-role" { - name = "${var.app-name}-iam-role" - path = "/${var.app-name}/" - assume_role_policy = data.aws_iam_policy_document.ec2-instance-assume-role-policy.json -} - -resource "aws_iam_role_policy_attachment" "attach-read-s3-nwp" { - role = aws_iam_role.app-role.name - policy_arn = var.s3_nwp_bucket.bucket_read_policy_arn -} - -resource "aws_iam_role_policy_attachment" "attach-read-s3-satellite" { - count = var.s3_satellite_bucket.bucket_read_policy_arn != "not-set" ? 1 : 0 - role = aws_iam_role.app-role.name - policy_arn = var.s3_satellite_bucket.bucket_read_policy_arn -} - -resource "aws_iam_role_policy_attachment" "attach-read-s3-ml" { - role = aws_iam_role.app-role.name - policy_arn = var.s3_ml_bucket.bucket_read_policy_arn -} diff --git a/terraform/modules/services/forecast_generic/variables.tf b/terraform/modules/services/forecast_generic/variables.tf deleted file mode 100644 index 6b001c95..00000000 --- a/terraform/modules/services/forecast_generic/variables.tf +++ /dev/null @@ -1,154 +0,0 @@ -variable "environment" { - type = string - description = "The Deployment environment" -} - -variable "region" { - type = string - description = "The AWS region" -} - -variable "app-name" { - type = string - description = "The name of the application" -} - -variable "rds_config" { - type = object({ - database_secret_arn = string - database_secret_read_policy_arn = string - }) - description = <