6
2

More than 3 years have passed since last update.

ECSのタスク定義でボリュームのマウントをする時のパラメータの書き方

Posted at

ボリュームプロパティ

事前にVolumesプロパティで、マウント先であるインスタンス側のボリュームを、パスを指定して命名しておく。

  Properties:
    Volumes:
      - Name: host_volume
        Host:
          SourcePath: /var/log

マウントパラメータ

マウント自体はmountPointsパラメータで定義される。
SourceVolumeパラメータには先ほど定義したマウント先のインスタンスのボリューム名を入れる。
この時、SourceVolumeで指定できるのは、Volumesプロパティで定義されたものだけなので注意。
ContainerPathパラメータにはマウントするコンテナ内のボリュームのパスをそのまま書けばよい。
ReadOnlyパラメータはデフォルトでfalse

        MountPoints:
          - SourceVolume: host_volume
            ContainerPath: /var/data/buffer
            ReadOnly: true

タスク定義

以下が全体像の例

TaskDefinition:
  Type: AWS::ECS::TaskDefinition
  Properties:
    Volumes:
      - Name: host_volume
        Host:
          SourcePath: /var/log
    ContainerDefinitions:
      - Name: xxxxxxxxxxx.dkr.ecr.ap-northeast-1.amazonaws.com/sample:latest
        Image: samples/sample-container-agent:latest
        Memory: 128
        MountPoints:
          - SourceVolume: host_volume
            ContainerPath: /var/data/buffer
            ReadOnly: true
        Environment:
          - Name: ENV
            Value: development
        Essential: false

cf.

6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2