Skip to main content

Create an AWS Batch compute environment

You can create an AWS Batch compute environment with Batch Forge or with existing resources. With Batch Forge, Seqera creates the Batch compute environments and job queues in your AWS account. To use AWS Batch compute environments and job queues that already exist, see Use existing resources. For everything you need in place first, see the AWS Batch checklist.

Intelligent Compute offers a better, more efficient experience for running pipelines. It is in private preview. To learn more, contact Seqera. See Intelligent Compute on AWS.

Prerequisites

You need the following:

caution

AWS Batch creates resources in your AWS account that AWS may charge you for. See Cloud costs for guidelines to manage cloud resources and prevent unexpected costs.

Create the compute environment with Batch Forge​

  1. In the workspace where you want to create the compute environment, select Compute Environments from the navigation menu.

  2. Select Add compute environment.

  3. Enter a descriptive name for this environment, for example, AWS Batch Spot (eu-west-1).

  4. Select AWS Batch as the target platform.

  5. From the Credentials drop-down, select your AWS credentials. To add credentials, see AWS Batch credentials.

  6. Select a Region, for example, eu-west-1 - Europe (Ireland). This region must match the location of the S3 bucket or the EFS or FSx file system that you plan to use as the work directory.

  7. In the Pipeline work directory field, enter or select from the drop-down the S3 bucket you created, for example, s3://seqera-bucket. To store Nextflow intermediate files in a folder inside the bucket, specify the folder path, for example, s3://seqera-bucket/nextflow-workdir. The bucket must be in the region that you selected in the previous step.

    note

    When you specify an S3 bucket as your work directory, Nextflow uses this bucket for its cloud cache by default. Seqera adds a cloudcache block to the Nextflow configuration file for all runs that use this compute environment. This block includes the path to a cloudcache folder in your work directory, for example, s3://seqera-bucket/cloudcache/.cache. To specify an alternative cache location, use the Nextflow config file field on the pipeline launch form.

    You can also specify a path in an EFS or FSx file system as your work directory. With EFS or FSx, go to the "EFS file system" or "FSx for Lustre" section, then specify an existing file system ID or let Seqera create a new file system. See EFS file system and FSx for Lustre file system.

    warning

    Using an EFS or FSx file system as your work directory is incompatible with Studios and causes errors with checkpoints and mounted data. If you use Studios, use an S3 bucket as your work directory.

  8. Optional: To share task results across runs, turn on Nextflow global cache and enter a Global cache location. To choose the location, see Nextflow global cache.

  9. Select Wave containers to make it easier to access private container repositories and to provision containers in your pipelines with the Wave containers service. See Wave containers.

  10. Select Fusion to access your S3-hosted data through the Fusion v2 virtual distributed file system. This speeds up most data operations. The Fusion v2 file system requires Wave containers. See Fusion file system for configuration details.

    Use Fusion v2 file system
    note

    The compute recommendations below are based on internal benchmarking performed by Seqera. Benchmark runs of nf-core/rnaseq used profile test_full, consisting of an input dataset with 16 FASTQ files and a total size of approximately 123.5 GB.

    Use Fusion with AWS NVMe instances (fast instance storage). This setup delivers the fastest performance when compared to environments that use only AWS EBS (Elastic Block Store).

    1. Use Seqera Platform version 23.1 or later.
    2. Use an S3 bucket as the pipeline work directory.
    3. Enable Wave containers, Fusion v2, and fast instance storage.
    4. Select the Batch Forge config mode.
    5. Fast instance storage requires an EC2 instance type that uses NVMe disks. Specify NVMe-based instance types in Instance types under Advanced options. If left unspecified, Platform selects instances from AWS NVMe-based instance type families. With Fusion snapshots enabled, Platform selects the recommended Fusion Snapshots instance types instead, where your region offers them. See Instance store temporary block storage for EC2 instances for more information.
    note

    When enabling fast instance storage, do not select the optimal instance type families (c4, m4, r4) for your compute environment as these are not NVMe-based instances. Specify AWS NVMe-based instance types, or leave the Instance types field empty for Platform to select NVMe instances for you.

    tip

    For large and long-lived production pipelines, select 8xlarge or above:

    • A local temp storage disk of at least 200 GB and a random read speed of 1000 MBps or more. To work with files larger than 100 GB, increase temp storage accordingly (400 GB or more).
    • Dedicated networking ensures a guaranteed network speed service level compared with "burstable" instances. See Instance network bandwidth for more information.

    When using Fusion v2 without fast instance storage, the following EBS settings are applied to optimize file system performance:

    • EBS boot disk size is increased to 100 GB
    • EBS boot disk type GP3 is selected
    • EBS boot disk throughput is increased to 325 MB/s

    Extensive benchmarking of Fusion v2 has demonstrated that the increased cost associated with these settings are generally outweighed by the costs saved due to decreased run time.

  11. Select Fusion snapshots to let Fusion automatically restore jobs interrupted by an AWS Spot instance reclamation. This option requires Fusion v2 and a Spot provisioning model. See Fusion Snapshots.

    caution

    Leave Instance types under Advanced options empty so that Seqera Platform applies the recommended instance types, or set them yourself. Do not enable Fusion Snapshots on an On-Demand compute environment.

  12. Set the Config mode to Batch Forge to let Seqera Platform create and manage your AWS Batch compute environments.

  13. Select a Provisioning model. To minimize compute costs, select Spot. You can specify an allocation strategy and instance types under Advanced options. If you omit the advanced options, Seqera Platform 23.2 and later versions default to BEST_FIT_PROGRESSIVE for On-Demand and SPOT_PRICE_CAPACITY_OPTIMIZED for Spot compute environments.

    note

    You can create a compute environment that launches either Spot or On-Demand instances. Spot instances can cost as little as 20% of On-Demand instances. Because Nextflow can automatically relaunch failed tasks, Spot is almost always the recommended provisioning model. When you choose Spot instances, Seqera also creates a dedicated queue that runs the main Nextflow job on a single On-Demand instance to prevent execution interruptions.

    From Nextflow version 24.10, the default Spot reclamation retry setting is 0 on AWS and Google. By default, no internal retries are attempted on these platforms. A Spot reclamation leads to an immediate failure, exposed to Nextflow in the same way as other generic failures (for example, returning exit code 1 on AWS). Nextflow treats these failures like any other job failure unless you configure a retry strategy. See Spot instance failures and retries.

  14. Enter the Max CPUs, for example, 64. This is the maximum number of combined CPUs (the sum of all instances' CPUs) that AWS Batch provisions at any time.

  15. Optional: Configure the features your pipelines need. See AWS Batch options for Fargate head jobs, GPUs, Graviton, additional S3 buckets, EFS and FSx file systems, and advanced options.

  16. Select Dispose resources to automatically delete all AWS resources that Seqera Platform created, including EFS and FSx file systems, when you delete the compute environment.

  17. Apply Resource labels to the cloud resources produced by this compute environment. Workspace default resource labels are prefilled.

  18. Optional: Expand Staging options and Environment variables to add pre- and post-run scripts, Nextflow configuration, or environment variables. See Common compute environment options.

  19. Select Add to finalize the compute environment setup. Seqera takes a few seconds to create all the AWS resources before you can launch pipelines.

Use existing resources​

Use existing resources when you cannot let Seqera create resources in your AWS account, or when your AWS Batch compute environments and job queues already exist. You create the AWS Batch resources, and Seqera submits jobs to the queues you specify.

Before you create the compute environment, you need the following:

  • The AWS Batch resources: the Batch service role, instance role, head job role, Spot Fleet role, launch template, Batch compute environments, and job queues. See Create AWS Batch resources manually.
  • The AWS Batch policy without the Batch Forge statements. See AWS Batch IAM policy.
  • Your tags on the AWS Batch resources, if you report on cost. See Cost reporting.

Follow the steps in Create the compute environment with Batch Forge, with these differences:

  • Work directory: The EFS and FSx for Lustre form options are available only with the Batch Forge config mode. To use an EFS or FSx file system as the work directory, create the file system and mount it on your AWS Batch compute environments yourself. See Work directory storage.
  • Fusion v2: Seqera does not set the instance types of your AWS Batch compute environments. For fast instance storage, use NVMe-based instance types in the AWS Batch compute environment that you created for the compute queue. Do not use the optimal instance type families (c4, m4, r4). Set the instance types when you create the AWS Batch compute environments. See Create the Batch compute environments.
  • Fusion snapshots: Restrict the instance types of the AWS Batch compute environment that you created for the compute queue to the recommended instance types.
  • Config mode: Set the Config mode to Manual, then enter the queues:
    • Head queue: The name of the AWS Batch queue where the Nextflow main job runs.
    • Compute queue: The name of the AWS Batch queue where tasks are submitted.
  • Batch Forge steps: The Provisioning model, Max CPUs, and Dispose resources steps apply to Batch Forge only. Skip them.
  • Advanced options: See Advanced options for existing resources.

The following also differ from Batch Forge:

  • Graviton: AWS Graviton instances (ARM64 CPU architecture) are not supported.
  • Fargate for head job: Not supported. The head job runs on EC2.
  • AWS CLI: Seqera installs the aws CLI on the instances only with Batch Forge. Install it in your launch template. See Create a launch template.
  • Resource labels: Seqera does not apply your resource labels to the AWS Batch compute environments and job queues.

Pre-flight checks​

Pre-flight checks confirm that a compute environment is usable before you launch a pipeline. Seqera runs them at three points:

  • When you create the compute environment: Seqera rejects the request if the selected credentials are INVALID or have been deleted. Seqera also rejects the request if the work directory bucket is not in the same region as the compute environment.
  • On a recurring schedule: Seqera re-checks the compute environment. If its credentials are INVALID, Seqera marks the compute environment INVALID and shows a banner with the error message.
  • Each time you launch a pipeline: Seqera blocks the launch if the compute environment or its credentials are INVALID, or if Wave is enabled and the Wave service connection is not active.

To clear an INVALID status, fix the cause, then open the ⋮ menu of the compute environment and select Validate. If the credentials are also INVALID, validate the credentials first.

A brief Wave reconnection does not block a launch. If the Wave connection stays down, Seqera blocks the launch but does not mark the compute environment INVALID. See Wave service connection is not active.

See Pre-flight checks for how Seqera validates credentials and compute environments, and Pre-flight checks troubleshooting for error messages.

Cost reporting​

Seqera shows an Estimated cost for each run on the Metrics tab of the run. The estimate is a heuristic, not a billing figure. See Seqera cost estimate.

For cost accounting, use resource labels with the AWS billing tools. Batch Forge tags the Batch compute environments and job queues that it creates with your resource labels. To report on them, activate the labels as cost allocation tags. See Include Seqera resource labels in AWS billing reports.

With existing resources, Seqera does not tag AWS Batch compute environments, job queues, or other resources that you create yourself. Their costs are not attributable in AWS Cost Explorer or your data exports until you tag them. See Resource label propagation to AWS.

Existing resources: create AWS Batch resources manually​

Set up AWS roles and Batch queues manually to deploy Nextflow workloads with Seqera Platform.

tip

Manual AWS Batch configuration is only necessary if you do not want Seqera Platform to create the required AWS Batch resources in your AWS account automatically. Seqera Platform creates them with an internal tool called Batch Forge.

Complete the following steps to configure the AWS Batch resources that Seqera Platform needs:

  1. Create the instance role policy.
  2. Create the AWS Batch service role.
  3. Create an EC2 instance role.
  4. Create a Nextflow head job 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 the instance role policy​

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

  1. In the IAM Console, select Create policy from the Policies page.

  2. Create a new policy with the following content:

    {
    "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",
    "batch:TagResource",
    "ecs:DescribeTasks",
    "ec2:DescribeInstances",
    "ec2:DescribeInstanceTypes",
    "ec2:DescribeInstanceAttribute",
    "ecs:DescribeContainerInstances",
    "ec2:DescribeInstanceStatus",
    "logs:Describe*",
    "logs:Get*",
    "logs:List*",
    "logs:Create*",
    "logs:Put*",
    "logs:StartQuery",
    "logs:StopQuery",
    "logs:TestMetricFilter",
    "logs:FilterLogEvents"
    ],
    "Resource": "*"
    }
    ]
    }
  3. Save it with the name seqera-batchjob.

Create the Batch service role​

Create a service role that AWS Batch uses to launch EC2 instances on your behalf:

  1. In the IAM Console, select Create role from the Roles page.
  2. Select AWS service as the trusted entity type, and Batch as the service.
  3. On the next page, the AWSBatchServiceRole is already attached. No further permissions are needed for this role.
  4. Enter seqera-servicerole as the role name and add an optional description and tags if needed, then select Create.

Create an EC2 instance role​

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

  1. In the IAM Console, select Create role from the Roles page.
  2. Select AWS service as the trusted entity type, EC2 as the service, and EC2 - Allows EC2 instances to call AWS services on your behalf as the use case.
  3. Select Next: Permissions. Search for the following policies to attach to the role:
    • AmazonEC2ContainerServiceforEC2Role
    • AmazonS3FullAccess (consider a custom policy that allows access only to specific S3 buckets)
    • seqera-batchjob (the instance role policy created earlier)
  4. Enter seqera-instancerole as the role name and add an optional description and tags if needed, then select Create.

If you enable data lineage in your workspace, attach the following additional policy to this role to allow access to the lineage S3 bucket:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "LineageListBucket",
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::seqera-lineage-<workspace-id>"
},
{
"Sid": "LineageObjectAccess",
"Effect": "Allow",
"Action": [
"s3:*Object",
"s3:AbortMultipartUpload"
],
"Resource": "arn:aws:s3:::seqera-lineage-<workspace-id>/*"
},
{
"Sid": "LineageObjectTagging",
"Effect": "Allow",
"Action": [
"s3:PutObjectTagging",
"s3:GetObjectTagging"
],
"Resource": "arn:aws:s3:::seqera-lineage-<workspace-id>/*"
}
]
}

Create a Nextflow head job role​

Create an IAM role for the Nextflow head job. This role is attached to the Nextflow head job container and grants it the permissions needed to orchestrate workflow tasks and retrieve task logs from CloudWatch. You specify this role in the Head job role field when you create a manual compute environment in Seqera Platform.

note

This role is separate from the EC2 instance role. The head job role is attached directly to the Nextflow container through the Batch job definition, while the instance role applies to the underlying EC2 instance.

  1. In the IAM Console, select Create policy from the Policies page.

  2. Create a new policy with the following content:

    {
    "Version": "2012-10-17",
    "Statement": [
    {
    "Sid": "BatchJobManagement",
    "Effect": "Allow",
    "Action": [
    "batch:DescribeJobQueues",
    "batch:CancelJob",
    "batch:SubmitJob",
    "batch:ListJobs",
    "batch:DescribeComputeEnvironments",
    "batch:TerminateJob",
    "batch:DescribeJobs",
    "batch:RegisterJobDefinition",
    "batch:DescribeJobDefinitions",
    "batch:TagResource",
    "ecs:DescribeTasks",
    "ec2:DescribeInstances",
    "ec2:DescribeInstanceTypes",
    "ec2:DescribeInstanceAttribute",
    "ecs:DescribeContainerInstances",
    "ec2:DescribeInstanceStatus"
    ],
    "Resource": "*"
    },
    {
    "Sid": "CloudWatchLogsAccess",
    "Effect": "Allow",
    "Action": [
    "logs:CreateLogGroup",
    "logs:CreateLogStream",
    "logs:DescribeLogGroups",
    "logs:DescribeLogStreams",
    "logs:FilterLogEvents",
    "logs:GetLogEvents",
    "logs:ListTagsLogGroup",
    "logs:PutLogEvents",
    "logs:StartQuery",
    "logs:StopQuery",
    "logs:TestMetricFilter"
    ],
    "Resource": "*"
    }
    ]
    }
    note

    logs:GetLogEvents is required for Nextflow to retrieve task stderr from CloudWatch when tasks fail. Without it, error reports for failed tasks show an AccessDeniedException instead of the actual task error.

  3. Save it with the name seqera-headjob-policy.

  4. Select Create role from the Roles page. Select AWS service as the trusted entity type and Elastic Container Service Task as the use case.

  5. Attach the seqera-headjob-policy policy to the role.

  6. Enter seqera-headjob-role as the role name and select Create.

Create an EC2 SpotFleet role​

With the EC2 SpotFleet role, you can use Spot instances when you run jobs in AWS Batch. Create a role for creating and launching Spot fleets, which are Spot instances with similar compute capabilities (that is, vCPUs and RAM):

  1. In the IAM Console, select Create role from the Roles page.
  2. Select AWS service as the trusted entity type, EC2 as the service, and EC2 - Spot Fleet Tagging as the use case.
  3. On the next page, the AmazonEC2SpotFleetTaggingRole is already attached. No further permissions are needed for this role.
  4. Enter seqera-fleetrole as the role name and add an optional description and tags if needed, then select Create.

Create a launch template​

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

  1. In the EC2 Console, select Create launch template from the Launch templates page.

  2. Scroll down to Advanced details and paste the following in the User data field:

    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary="//"

    --//
    Content-Type: text/cloud-config; charset="us-ascii"

    #cloud-config
    write_files:
    - path: /root/custom-ce.sh
    permissions: 0744
    owner: root
    content: |
    #!/usr/bin/env bash
    exec > >(tee /var/log/tower-forge.log|logger -t TowerForge -s 2>/dev/console) 2>&1
    ##
    yum install -q -y jq sed wget unzip nvme-cli lvm2
    ## install CloudWatch agent
    curl -s https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm -o amazon-cloudwatch-agent.rpm
    rpm -U ./amazon-cloudwatch-agent.rpm
    rm -f ./amazon-cloudwatch-agent.rpm
    curl -s https://nf-xpack.seqera.io/amazon-cloudwatch-agent/config-v0.4.json \
    # | sed 's/$FORGE_ID/<your custom ID>/g' \
    > /opt/aws/amazon-cloudwatch-agent/bin/config.json
    /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
    -a fetch-config \
    -m ec2 \
    -s \
    -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json
    ## format NVMe storage for Fusion
    mkdir -p /scratch/fusion
    NVME_DISKS=($(nvme list | grep 'Amazon EC2 NVMe Instance Storage' | awk '{ print $1 }'))
    NUM_DISKS=${#NVME_DISKS[@]}
    if (( NUM_DISKS > 0 )); then
    if (( NUM_DISKS == 1 )); then
    mkfs -t xfs ${NVME_DISKS[0]}
    mount ${NVME_DISKS[0]} /scratch/fusion
    else
    pvcreate ${NVME_DISKS[@]}
    vgcreate scratch_fusion ${NVME_DISKS[@]}
    lvcreate -l 100%FREE -n volume scratch_fusion
    mkfs -t xfs /dev/mapper/scratch_fusion-volume
    mount /dev/mapper/scratch_fusion-volume /scratch/fusion
    fi
    fi
    chmod a+w /scratch/fusion
    ## ECS configuration
    mkdir -p /etc/ecs
    echo ECS_IMAGE_PULL_BEHAVIOR=once >> /etc/ecs/ecs.config
    echo ECS_ENABLE_AWSLOGS_EXECUTIONROLE_OVERRIDE=true >> /etc/ecs/ecs.config
    echo ECS_ENABLE_SPOT_INSTANCE_DRAINING=true >> /etc/ecs/ecs.config
    echo ECS_CONTAINER_CREATE_TIMEOUT=10m >> /etc/ecs/ecs.config
    echo ECS_CONTAINER_START_TIMEOUT=10m >> /etc/ecs/ecs.config
    echo ECS_CONTAINER_STOP_TIMEOUT=10m >> /etc/ecs/ecs.config
    echo ECS_MANIFEST_PULL_TIMEOUT=10m >> /etc/ecs/ecs.config
    ## stop docker
    systemctl stop docker
    ## install AWS CLI
    curl -s https://nf-xpack.seqera.io/miniconda-awscli/miniconda-25.3.1-awscli-1.40.12.tar.gz \
    | tar xz -C /
    export PATH=$PATH:/home/ec2-user/miniconda/bin
    ln -s /home/ec2-user/miniconda/bin/aws /usr/bin/aws
    ## restart docker
    systemctl start docker
    systemctl enable --now --no-block ecs
    ## kernel settings to prevent OOM
    echo "1258291200" > /proc/sys/vm/dirty_bytes
    echo "629145600" > /proc/sys/vm/dirty_background_bytes

    runcmd:
    - bash /root/custom-ce.sh

    --//--
  3. To prepend a custom identifier to the CloudWatch log streams for AWS resources created by your manual compute environment, uncomment the | sed 's/$FORGE_ID/<your custom ID>/g' \ line and replace <your custom ID> with your custom identifier. If omitted, $FORGE_ID remains as-is in the config.

  4. Save the template with the name seqera-launchtemplate.

Create the Batch compute environments​

caution

AWS Graviton instances (ARM64 CPU architecture) are not supported in manual compute environments. To use Graviton instances, create your AWS Batch compute environment with Batch Forge.

Nextflow uses two job queues during workflow execution:

  • A head queue to run the Nextflow application
  • A compute queue where Nextflow submits job executions

The compute queue can use a compute environment with Spot instances, but the head queue requires an on-demand compute environment. If you use an on-demand compute environment for compute jobs, you can use the same job queue for both head and compute.

note

Spot instances can reduce your AWS compute costs, provided your workflow compute tasks can run on ephemeral instances.

Create a compute environment for each queue in the AWS Batch console:

The head queue requires an on-demand compute environment. Do not select Use Spot instances during compute environment creation.

  1. In the Batch Console, select Create on the Compute environments page.
  2. Select Amazon EC2 as the compute environment configuration.
    note

    Seqera AWS Batch compute environments created with Batch Forge support using Fargate for the head job, but manual compute environments must use EC2.

  3. Enter a name of your choice, and apply the seqera-servicerole and seqera-instancerole.
  4. When you create the Seqera compute environment, enter the ARN of seqera-headjob-role in the Head job role field.
  5. Enter vCPU limits and instance types, if needed.
    note

    To use the same queue for both head and compute tasks, you must assign sufficient resources to your compute environment.

  6. Expand Additional configuration and select the seqera-launchtemplate from the Launch template drop-down.
  7. Configure VPCs, subnets, and security groups on the next page as needed.
  8. Review your configuration and select Create compute environment.

Create the Batch queue​

Create a Batch queue to associate with each compute environment.

note

You only need to create one queue if you use on-demand instances for your workflow compute tasks. Compute environments with Spot instances require separate queues for the head and compute tasks.

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

Use the AWS resources created in this section to create your compute environment. See Use existing resources.

Next steps​

To run pipelines in your AWS Batch compute environment, see Launch pipelines.