首页 > 解决方案 > 如何在 aws_batch_job_definition 中使用 terraform 定义 ephemeralStorage?

问题描述

我正在尝试使用 terraform 在我的 aws_batch_job_definition 中定义ephemeralStorage ,但无法正常工作。我不确定我应该将参数放在 JSON 中的哪个位置,也不是 GUI 中的位置。

这是我的工作定义:

resource "aws_batch_job_definition" "sample" {
  name = "sample_job_definition"
  type = "container"

  platform_capabilities = [
    "FARGATE",
  ]

  container_properties = <<CONTAINER_PROPERTIES
{
    "command": ["bash", "/root/plotter.sh"],
    "image": "995648859937.dkr.ecr.us-east-1.amazonaws.com/chia:latest",
    "fargatePlatformConfiguration": {
      "platformVersion": "LATEST"
    },
    "resourceRequirements": [
      {"type": "VCPU", "value": "4"},
      {"type": "MEMORY", "value": "15360"}
    ],
    "networkMode": "awsvpc",
    "networkConfiguration": {
      "assignPublicIp" : "ENABLED"
    },
    "executionRoleArn": "${aws_iam_role.ecs_task_execution_role.arn}",
    "jobRoleArn": "${aws_iam_role.ecs_task_role.arn}"
}
CONTAINER_PROPERTIES
}

标签: amazon-web-servicesterraformterraform-provider-awsaws-fargateaws-batch

解决方案


我们也一直在努力寻找这方面的信息,但您似乎找不到。

最好的解决方法似乎是附加和安装 EFS 卷,例如

{
  "containerProperties": [
    {
      "name": "container-using-efs",
      "image": "amazonlinux:2",
      "command": [
        "ls",
        "-la",
        "/mount/efs"
      ],
      "mountPoints": [
        {
          "sourceVolume": "myEfsVolume",
          "containerPath": "/mount/efs",
          "readOnly": true
        }
      ],
      "volumes": [
        {
          "name": "myEfsVolume",
          "efsVolumeConfiguration": {
            "fileSystemId": "fs-12345678",
            "rootDirectory": "/path/to/my/data",
            "transitEncryption": "ENABLED",
            "transitEncryptionPort": integer,
            "authorizationConfig": {
              "accessPointId": "fsap-1234567890abcdef1",
              "iam": "ENABLED"
            }
          }
        }
      ]
    }
  ]
}

推荐阅读