title: Attach Volume EFS in ECS
body: <p>When trying to mount an EFS file system together with ECS, I get the following error:</p>
  <p>ResourceInitializationError: failed to invoke EFS utils commands to set up EFS volumes: stderr: mount.nfs4: Connection reset by peer : unsuccessful EFS utils command execution; code: 32</p>
  <p>My Stack:</p>
  <pre><code>--- 
    AWSTemplateFormatVersion: &quot;2010-09-09&quot;
    Description: &quot;Template Test&quot;
    Outputs: 
      FileSystemID: 
        Description: &quot;File system ID&quot;
        Value: 
          Ref: FileSystem
    Parameters: 
      VolumeName: 
        Default: myEFSvolume
        Description: &quot;The name to be used for the EFS volume&quot;
        MinLength: &quot;1&quot;
        Type: String
    Resources: 
      ECSCluster: 
        Properties: 
          ClusterName: jenkins-cluster
        Type: &quot;AWS::ECS::Cluster&quot;
      EFSMountTarget1: 
        Properties: 
          FileSystemId: 
            Ref: FileSystem
          SecurityGroups: 
            - &quot;sg-0082cea75ba714505&quot;
          SubnetId: &quot;subnet-0f0b0d3aaada62b6c&quot;
        Type: &quot;AWS::EFS::MountTarget&quot;
      FileSystem: 
        Properties: 
          Encrypted: true
          FileSystemTags: 
            - Key: Name
              Value: 
                Ref: VolumeName
          PerformanceMode: generalPurpose
        Type: &quot;AWS::EFS::FileSystem&quot;
      JenkinsService: 
        Type: &quot;AWS::ECS::Service&quot;
        Properties: 
          Cluster: 
            Ref: ECSCluster
          DesiredCount: 2
          LaunchType: FARGATE
          NetworkConfiguration: 
            AwsvpcConfiguration:
              AssignPublicIp: ENABLED
              SecurityGroups: 
                - &quot;sg-0082cea75ba714505&quot;
              Subnets: 
                - &quot;subnet-0f0b0d3aaada62b6c&quot;
          PlatformVersion: &quot;1.4.0&quot;
          ServiceName: JenkinsService
          
          TaskDefinition: 
            Ref: JenkinsTaskDef
      JenkinsTaskDef: 
        Type: &quot;AWS::ECS::TaskDefinition&quot;
        Properties:
          Cpu: 2048
          Memory: 4096
          Family: efs-example-task-fargate
          NetworkMode: awsvpc
          TaskRoleArn: &quot;arn:xxxxx/ecs&quot;
          ExecutionRoleArn: &quot;arn:xxxxxx:role/ecs&quot;
          RequiresCompatibilities:
            - FARGATE 
          ContainerDefinitions: 
            - Cpu: 1024
              Memory: 2048
              PortMappings:
                - HostPort: 8080
                  ContainerPort: 8080
                - HostPort: 50000
                  ContainerPort: 50000
              image: &quot;xxxxxxx.dkr.ecr.us-east-1.amazonaws.com/sample:latest&quot;
              mountPoints: 
                - containerPath: /var/jenkins_home
                  readOnly: false
                  sourceVolume: myEfsVolume
              name: jenkins
          volumes:
            - name: myEfsVolume  
              efsVolumeConfiguration: 
                fileSystemId: 
                  Ref: FileSystem
                rootDirectory: /var/jenkins_home
                transitEncryption: ENABLED 
      
  </code></pre>
  <p>I am performing according to documentation:</p>
  <p><a href="https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_EFSVolumeConfiguration.html" rel="noreferrer">https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_EFSVolumeConfiguration.html</a></p>