ボリュームプロパティ
事前に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.