|
1 | 1 | # Job Definition |
2 | 2 | resource "aws_batch_job_definition" "generate_batch_jd_metroman" { |
3 | | - name = "${var.prefix}-metroman" |
4 | | - type = "container" |
5 | | - container_properties = <<CONTAINER_PROPERTIES |
6 | | - { |
7 | | - "image": "${local.account_id}.dkr.ecr.us-west-2.amazonaws.com/${var.prefix}-metroman", |
8 | | - "executionRoleArn": "${data.aws_iam_role.exe_role.arn}", |
9 | | - "jobRoleArn": "${data.aws_iam_role.job_role.arn}", |
10 | | - "fargatePlatformConfiguration": { "platformVersion": "LATEST" }, |
11 | | - "logConfiguration": { |
12 | | - "logDriver" : "awslogs", |
13 | | - "options": { |
14 | | - "awslogs-group" : "${data.aws_cloudwatch_log_group.cw_log_group.name}" |
| 3 | + name = "${var.prefix}-metroman" |
| 4 | + type = "container" |
| 5 | + platform_capabilities = ["FARGATE"] |
| 6 | + propagate_tags = true |
| 7 | + tags = { "job_definition": "${var.prefix}-metroman" } |
| 8 | + |
| 9 | + container_properties = jsonencode({ |
| 10 | + image = "${local.account_id}.dkr.ecr.us-west-2.amazonaws.com/${var.prefix}-metroman:${var.image_tag}" |
| 11 | + executionRoleArn = var.iam_execution_role_arn |
| 12 | + jobRoleArn = var.iam_job_role_arn |
| 13 | + fargatePlatformConfiguration = { |
| 14 | + platformVersion = "LATEST" |
| 15 | + } |
| 16 | + logConfiguration = { |
| 17 | + logDriver = "awslogs" |
| 18 | + options = { |
| 19 | + awslogs-group = aws_cloudwatch_log_group.cw_log_group.name |
15 | 20 | } |
16 | | - }, |
17 | | - "resourceRequirements": [ |
18 | | - {"type": "MEMORY", "value": "8192"}, |
19 | | - {"type": "VCPU", "value": "4"} |
20 | | - ], |
21 | | - "mountPoints": [ |
22 | | - { |
23 | | - "sourceVolume": "input", |
24 | | - "containerPath": "/mnt/data/input", |
25 | | - "readOnly": true |
26 | | - }, |
27 | | - { |
28 | | - "sourceVolume": "flpe", |
29 | | - "containerPath": "/mnt/data/output", |
30 | | - "readOnly": false |
| 21 | + } |
| 22 | + resourceRequirements = [{ |
| 23 | + type = "MEMORY" |
| 24 | + value = "8192" |
| 25 | + }, { |
| 26 | + type = "VCPU", |
| 27 | + value = "4" |
| 28 | + }] |
| 29 | + mountPoints = [{ |
| 30 | + sourceVolume = "input", |
| 31 | + containerPath = "/mnt/data/input" |
| 32 | + readOnly = false |
| 33 | + }, { |
| 34 | + sourceVolume = "flpe" |
| 35 | + containerPath = "/mnt/data/output" |
| 36 | + readOnly = false |
| 37 | + }] |
| 38 | + volumes = [{ |
| 39 | + name = "input" |
| 40 | + efsVolumeConfiguration = { |
| 41 | + fileSystemId = var.efs_file_system_ids["input"] |
| 42 | + rootDirectory = "/" |
31 | 43 | } |
32 | | - ], |
33 | | - "volumes": [ |
34 | | - { |
35 | | - "name": "input", |
36 | | - "efsVolumeConfiguration": { |
37 | | - "fileSystemId": "${data.aws_efs_file_system.aws_efs_input.file_system_id}", |
38 | | - "rootDirectory": "/" |
39 | | - } |
40 | | - }, |
41 | | - { |
42 | | - "name": "flpe", |
43 | | - "efsVolumeConfiguration": { |
44 | | - "fileSystemId": "${data.aws_efs_file_system.aws_efs_flpe.file_system_id}", |
45 | | - "rootDirectory": "/metroman" |
46 | | - } |
| 44 | + }, { |
| 45 | + name = "flpe" |
| 46 | + efsVolumeConfiguration = { |
| 47 | + fileSystemId = var.efs_file_system_ids["flpe"] |
| 48 | + rootDirectory = "/metroman" |
47 | 49 | } |
48 | | - ] |
49 | | - } |
50 | | - CONTAINER_PROPERTIES |
51 | | - platform_capabilities = ["FARGATE"] |
52 | | - propagate_tags = true |
53 | | - tags = { "job_definition": "${var.prefix}-metroman" } |
| 50 | + }] |
| 51 | + }) |
| 52 | +} |
| 53 | + |
| 54 | +# Log group |
| 55 | +resource "aws_cloudwatch_log_group" "cw_log_group" { |
| 56 | + name = "/aws/batch/job/${var.prefix}-metroman/" |
54 | 57 | } |
0 commit comments