【问题标题】:How to define ephemeralStorage using terraform in a aws_batch_job_definition?如何在 aws_batch_job_definition 中使用 terraform 定义 ephemeralStorage?
【发布时间】:2021-08-01 20:43:37
【问题描述】:

我正在尝试使用 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
}

【问题讨论】:

  • 您说它不起作用,但您的问题表明没有尝试使其起作用。你试过什么没用?您是否收到错误或存储大小不是您指定的?
  • Ops,我应该更清楚。我尝试在容器属性和 resourceRequirements 中设置"ephemeralStorage": {"sizeInGiB": 200 },,但没有成功(磁盘大小仍然默认为 20GB)
  • 尝试将platformVersion明确设置为1.4.0

标签: amazon-web-services terraform terraform-provider-aws aws-fargate aws-batch


【解决方案1】:

我们也一直在努力寻找这方面的信息,而 appears 你找不到。

最好的解决方法似乎是附加和安装 EFS 卷,e.g:

{
  "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"
            }
          }
        }
      ]
    }
  ]
}

【讨论】:

    猜你喜欢
    • 2021-05-02
    • 2023-03-29
    • 1970-01-01
    • 2021-07-01
    • 2020-06-28
    • 1970-01-01
    • 1970-01-01
    • 2019-11-17
    • 2020-11-23
    相关资源
    最近更新 更多