@@ -329,7 +329,8 @@ private String getTaskDefinition(Authentication user, ContainerSpec spec, EcsSpe
329329 .dockerLabels (dockerLabels )
330330 .logConfiguration (getLogConfiguration (proxy .getSpecId ()))
331331 .mountPoints (volumes .getSecond ())
332- .secrets (getSecrets (specExtension ));
332+ .secrets (getSecrets (specExtension ))
333+ .readonlyRootFilesystem (specExtension .getEcsReadonlyRootFilesystem ().getValueOrDefault (false ));
333334
334335 String credentials = specExtension .getEcsRepositoryCredentialsParameter ().getValueOrDefault (defaultRepositoryCredentialsParameter );
335336 if (credentials != null && !credentials .isBlank ()) {
@@ -375,7 +376,7 @@ private LogConfiguration getLogConfiguration(String specId) {
375376
376377 private Pair <List <Volume >, List <MountPoint >> getVolumes (ContainerSpec spec , EcsSpecExtension specExtension ) {
377378 List <String > volumeNames = new ArrayList <>();
378- List <Volume > efsVolumeConfigurations = new ArrayList <>();
379+ List <Volume > volumeConfigurations = new ArrayList <>();
379380 for (EcsEfsVolume volume : specExtension .getEcsEfsVolumes ()) {
380381 EFSVolumeConfiguration .Builder efsVolumeConfiguration = EFSVolumeConfiguration .builder ();
381382 efsVolumeConfiguration .fileSystemId (volume .getFileSystemId ().getValue ());
@@ -397,10 +398,18 @@ private Pair<List<Volume>, List<MountPoint>> getVolumes(ContainerSpec spec, EcsS
397398 .name (volume .getName ().getValue ())
398399 .build ();
399400
400- efsVolumeConfigurations .add (finalVolume );
401+ volumeConfigurations .add (finalVolume );
401402 volumeNames .add (volume .getName ().getValue ());
402403 }
403404
405+ for (String volume : specExtension .getEcsBindVolumes ()) {
406+ volumeConfigurations .add (Volume .builder ()
407+ .name (volume )
408+ .build ()
409+ );
410+ volumeNames .add (volume );
411+ }
412+
404413 List <MountPoint > mountPoints = new ArrayList <>();
405414 if (spec .getVolumes ().isPresent ()) {
406415 for (String volume : spec .getVolumes ().getValue ()) {
@@ -411,7 +420,7 @@ private Pair<List<Volume>, List<MountPoint>> getVolumes(ContainerSpec spec, EcsS
411420 String name = components [0 ];
412421 String containerPath = components [1 ];
413422 if (!volumeNames .contains (name )) {
414- throw new IllegalArgumentException (String .format ("Invalid volume configuration: %s, no corresponding EFS volume definition found" , volume ));
423+ throw new IllegalArgumentException (String .format ("Invalid volume configuration: %s, no corresponding ( EFS or bind) volume definition found" , volume ));
415424 }
416425
417426 MountPoint .Builder mountPoint = MountPoint .builder ();
@@ -430,7 +439,21 @@ private Pair<List<Volume>, List<MountPoint>> getVolumes(ContainerSpec spec, EcsS
430439 }
431440 }
432441
433- return Pair .of (efsVolumeConfigurations , mountPoints );
442+ if (specExtension .ecsReadonlyRootFilesystem .getValueOrDefault (false )) {
443+ // if filesystem is read-only, mount read-write volume on /tmp
444+ volumeConfigurations .add (Volume .builder ()
445+ .name ("tmp" )
446+ .build ()
447+ );
448+
449+ mountPoints .add (MountPoint .builder ()
450+ .sourceVolume ("tmp" )
451+ .containerPath ("/tmp" )
452+ .build ()
453+ );
454+ }
455+
456+ return Pair .of (volumeConfigurations , mountPoints );
434457 }
435458
436459 private List <Secret > getSecrets (EcsSpecExtension specExtension ) {
0 commit comments