Skip to content

Manual AWS Batch configuration

This page describes how to set up AWS roles and Batch queues manually for the deployment of Nextflow workloads with Seqera Platform Enterprise.

Manual configuration of AWS Batch is only necessary if you don't use Tower Forge. Tower Forge will automatically create the required AWS Batch queues.

Complete the following procedures to configure AWS Batch manually:

  1. Create a user policy.
  2. Create the instance role policy.
  3. Create the AWS Batch service role.
  4. Create an EC2 Instance role.
  5. Create an EC2 SpotFleet role.
  6. Create a launch template.
  7. Create the AWS Batch compute environments.
  8. Create the AWS Batch queue.

Create a user policy#

Create the policy for the user launching Nextflow jobs:

  1. Go to the IAM Console.
  2. Go to the Policy page.
  3. Create a new policy with the following content:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "Stmt1530313170000",
                "Effect": "Allow",
                "Action": [
                    "batch:CancelJob",
                    "batch:RegisterJobDefinition",
                    "batch:DescribeComputeEnvironments",
                    "batch:DescribeJobDefinitions",
                    "batch:DescribeJobQueues",
                    "batch:DescribeJobs",
                    "batch:ListJobs",
                    "batch:SubmitJob",
                    "batch:TerminateJob"
                ],
                "Resource": [
                    "*"
                ]
            }
        ]
    }
    
  4. Save with it the name nf-tower-user.

Create the instance role policy#

Create the policy with a role that allows Seqera to submit Batch jobs on your EC2 instances:

  1. Go to the IAM Console.
  2. Go to the Policy page.
  3. Create a new policy with the following content:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "VisualEditor0",
                "Effect": "Allow",
                "Action": [
                    "batch:DescribeJobQueues",
                    "batch:CancelJob",
                    "batch:SubmitJob",
                    "batch:ListJobs",
                    "batch:DescribeComputeEnvironments",
                    "batch:TerminateJob",
                    "batch:DescribeJobs",
                    "batch:RegisterJobDefinition",
                    "batch:DescribeJobDefinitions",
                    "ecs:DescribeTasks",
                    "ec2:DescribeInstances",
                    "ec2:DescribeInstanceTypes",
                    "ec2:DescribeInstanceAttribute",
                    "ecs:DescribeContainerInstances",
                    "ec2:DescribeInstanceStatus",
                    "logs:Describe*",
                    "logs:Get*",
                    "logs:List*",
                    "logs:StartQuery",
                    "logs:StopQuery",
                    "logs:TestMetricFilter",
                    "logs:FilterLogEvents"
                ],
                "Resource": "*"
            }
        ]
    }
    
  4. Save it with the name nf-tower-batchjob.

Create the Batch Service role#

Create a service role used by AWS Batch to launch EC2 instances on your behalf:

  1. Go to the IAM Console.
  2. Select Roles.
  3. Select Create role.
  4. Select AWS service as the trusted entity.
  5. Select Batch as the service to use the role.
  6. Select Next: Permissions.
  7. In Attached permissions policies, the AWSBatchServiceRole is already attached.
  8. Select Next: Tags (adding tags is optional).
  9. Select Next: Review.
  10. Set the Role Name to nf-tower-servicerole.
  11. Select Create role.

Create an EC2 instance role#

Create a role that controls which AWS resources the EC2 instances launched by AWS Batch can access:

  1. Go to the IAM Console.
  2. Select Roles.
  3. Select Create role.
  4. Select AWS service as the trusted entity.
  5. Select EC2 from the larger services list.
  6. Select EC2 - Allows EC2 instances to call AWS services on your behalf as the use case.
  7. Select Next: Permissions.

    • Enter ContainerService in the search field for policies
    • Select the checkbox next to AmazonEC2ContainerServiceforEC2Role to attach the policy
    • Enter S3 in the search field for policies
    • Select the checkbox next to AmazonS3FullAccess to attach the policy (you may want to use to use a custom policy to allow access only on specific S3 buckets)
  8. Search for and attach the custom policy nf-tower-batchjob.

  9. Select Next: Tags (adding tags is optional).
  10. Select Next: Review.
  11. Set the Role Name to nf-tower-instancerole.
  12. Select Create role.

Create an EC2 SpotFleet role#

The EC2 SpotFleet role allows you to use Spot instances when you run jobs in AWS Batch. Create a role for the creation and launch of Spot fleets — Spot instances with similar compute capabilities (i.e., vCPUs and RAM):

  1. Go to the IAM Console.
  2. Select Roles.
  3. Select Create role.
  4. Select AWS service as the trusted entity.
  5. Select EC2 from the larger services list.
  6. Select EC2 - Spot Fleet Tagging as the use case.
    • In Attached permissions policies, the AmazonEC2SpotFleetTaggingRole is already attached.
  7. Select Next: Tags (adding tags is optional).
  8. Select Next: Review.
  9. Set the Role Name to nf-tower-fleetrole.
  10. Select Create role.

Create a launch template#

Create a launch template to configure the EC2 instances deployed by Batch jobs:

  1. Go to the EC2 Console.
  2. Select Launch template.
  3. Create a new launch template which uses the User Data (in the Advanced details section) shown below:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary="//"
    
    --//
    Content-Type: text/x-shellscript; charset="us-ascii"
    
    #!/bin/sh
    su - root << 'EOF'
    (
    set -x
    ## install awscli
    USER=/home/ec2-user
    export PATH=/usr/local/bin:$PATH
    yum install -y jq python27-pip sed wget bzip2
    pip install -U boto3
    wget -q https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
    bash Miniconda3-latest-Linux-x86_64.sh -b -f -p $USER/miniconda
    $USER/miniconda/bin/conda install -c conda-forge -y awscli
    rm Miniconda3-latest-Linux-x86_64.sh
    chown -R ec2-user:ec2-user $USER/miniconda
    ) &>> ~/boot.log
    EOF
    cp ~/boot.log ~ec2-user/boot.log
    
    --//--
    
  4. Save it with the name nf-tower-launchtemplate.

Create the Batch compute environments#

Create your AWS Batch compute environment from the Batch console:

  1. Go to the Batch Console.
  2. Create a new compute environment specifying the Instance profile, Service role, Fleet role and Launch template created previously.
  3. Save it with a name of your choice.

Create the Batch queue#

Create a Batch queue to be associated with your compute environment:

  1. Go to the Batch Console.
  2. Create a new queue.
  3. Associate the queue with the compute environment created in the previous step.
  4. Save it with a name of your choice.
Back to top