|
| 1 | +module "ecr" { |
| 2 | + source = "terraform-aws-modules/ecr/aws" |
| 3 | + version = "~> 3.0" |
| 4 | + |
| 5 | + repository_name = local.prefix |
| 6 | + repository_image_scan_on_push = true |
| 7 | + repository_encryption_type = "KMS" |
| 8 | + repository_force_delete = var.force_delete |
| 9 | + repository_image_tag_mutability = var.image_tags_mutable ? "MUTABLE" : "IMMUTABLE" |
| 10 | + repository_kms_key = aws_kms_key.fargate.arn |
| 11 | + repository_lifecycle_policy = jsonencode(yamldecode(templatefile( |
| 12 | + "${path.module}/templates/repository-lifecycle.yaml.tftpl", { |
| 13 | + untagged_image_retention : var.untagged_image_retention |
| 14 | + } |
| 15 | + ))) |
| 16 | + |
| 17 | + |
| 18 | + tags = var.tags |
| 19 | +} |
| 20 | + |
| 21 | +module "ecs_task" { |
| 22 | + source = "HENNGE/ecs/aws//modules/core/task" |
| 23 | + version = "~> 5.3" |
| 24 | + |
| 25 | + name = local.prefix |
| 26 | + # cluster = module.ecs.arn |
| 27 | + # container_name = local.prefix |
| 28 | + cpu = var.cpu |
| 29 | + memory = var.memory |
| 30 | + daemon_role = aws_iam_role.execution.arn |
| 31 | + task_role = aws_iam_role.task.arn |
| 32 | + requires_compatibilities = ["FARGATE"] |
| 33 | + network_mode = "awsvpc" |
| 34 | + |
| 35 | + volume_configurations = [ |
| 36 | + { |
| 37 | + name = "aws-lib" |
| 38 | + }, |
| 39 | + { |
| 40 | + name = "logs" |
| 41 | + }, |
| 42 | + { |
| 43 | + name = "senzing-home" |
| 44 | + } |
| 45 | + ] |
| 46 | + |
| 47 | + container_definitions = jsonencode(yamldecode(templatefile( |
| 48 | + "${path.module}/templates/container_definitions.yaml.tftpl", { |
| 49 | + name = local.prefix |
| 50 | + cpu = var.cpu - 256 |
| 51 | + memory = var.memory - 512 |
| 52 | + image = "${local.image_url}:${local.image_tag}" |
| 53 | + container_command = var.container_command |
| 54 | + container_port = var.container_port |
| 55 | + log_group = aws_cloudwatch_log_group.service.name |
| 56 | + region = data.aws_region.current.region |
| 57 | + namespace = "${var.project}/${var.service}" |
| 58 | + env_vars = var.environment_variables |
| 59 | + otel_log_level = var.otel_log_level |
| 60 | + otel_ssm_arn = module.otel_config.ssm_parameter_arn |
| 61 | + env_secrets = var.environment_secrets |
| 62 | + |
| 63 | + volumes = { |
| 64 | + # Needed to support SMS agent and ecs exec. |
| 65 | + aws-lib = { |
| 66 | + name = "aws-lib" |
| 67 | + mount = "/var/lib/aws" |
| 68 | + }, |
| 69 | + logs = { |
| 70 | + name = "logs", |
| 71 | + mount = "/var/log" |
| 72 | + }, |
| 73 | + senzing-home = { |
| 74 | + name = "senzing-home" |
| 75 | + mount = "/home/senzing" |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + ))) |
| 80 | + |
| 81 | + tags = var.tags |
| 82 | +} |
0 commit comments