diff --git a/provider/ecs/ecs.go b/provider/ecs/ecs.go index e6f321c..2e8fcfe 100644 --- a/provider/ecs/ecs.go +++ b/provider/ecs/ecs.go @@ -248,6 +248,20 @@ func (e *ECS) CreateTaskDefinition(d service.Deploy) (*string, error) { e.TaskDefinition.SetPlacementConstraints(pcs) } + // volumes + if len(d.Volumes) > 0 { + var volumes []*ecs.Volume + for _, vol := range d.Volumes { + volumes = append(volumes, &ecs.Volume{ + Name: aws.String(vol.Name), + Host: &ecs.HostVolumeProperties{ + SourcePath: aws.String(vol.Host.SourcePath), + }, + }) + } + e.TaskDefinition.SetVolumes(volumes) + } + // loop over containers for _, container := range d.Containers { @@ -343,6 +357,19 @@ func (e *ECS) CreateTaskDefinition(d service.Deploy) (*string, error) { containerDefinition.SetEnvironment(environment) } + // MountPoints + if len(container.MountPoints) > 0 { + var mps []*ecs.MountPoint + for _, mp := range container.MountPoints { + mps = append(mps, &ecs.MountPoint{ + ContainerPath: aws.String(mp.ContainerPath), + SourceVolume: aws.String(mp.SourceVolume), + ReadOnly: aws.Bool(mp.ReadOnly), + }) + } + containerDefinition.SetMountPoints(mps) + } + e.TaskDefinition.ContainerDefinitions = append(e.TaskDefinition.ContainerDefinitions, containerDefinition) } diff --git a/service/deploy.go b/service/deploy.go index 02733ed..e7db23c 100644 --- a/service/deploy.go +++ b/service/deploy.go @@ -25,6 +25,7 @@ type Deploy struct { LaunchType string `json:"launchType"` DeregistrationDelay int64 `json:"deregistrationDelay"` Stickiness DeployStickiness `json:"stickiness"` + Volumes []DeployVolume `json:"volumes"` } type DeployContainer struct { ContainerName string `json:"containerName" binding:"required"` @@ -39,11 +40,17 @@ type DeployContainer struct { CPU int64 `json:"cpu"` CPUReservation int64 `json:"cpuReservation"` Environment []*DeployContainerEnvironment `json:"environment"` + MountPoints []*DeployContainerMountPoint `json:"mountPoints"` } type DeployContainerEnvironment struct { Name string `json:"name"` Value string `json:"value"` } +type DeployContainerMountPoint struct { + ContainerPath string `json:"containerPath"` + SourceVolume string `json:"sourceVolume"` + ReadOnly bool `json:"readonly"` +} type DeployNetworkConfiguration struct { AssignPublicIp string `json:"assignPublicIp"` SecurityGroups []string `json:"securityGroups"` @@ -73,6 +80,13 @@ type DeployStickiness struct { Enabled bool `json:"enabled"` Duration int64 `json:"duration"` } +type DeployVolume struct { + Host DeployVolumeHost `json:"host"` + Name string `json:"name"` +} +type DeployVolumeHost struct { + SourcePath string `json:"sourcePath"` +} type DeployResult struct { ServiceName string `json:"serviceName"`