AWS Batch
This guide assumes you have an existing Amazon Web Service (AWS) account.
The AWS Batch service quota for job queues is 50 per account. For more information on AWS Batch service quotas, see AWS Batch service quotas.
There are two ways to create a Seqera Platform compute environment for AWS Batch:
- Automatically: this option lets Seqera automatically create the required AWS Batch resources in your AWS account, using an internal tool within Seqera Platform called "Forge". This removes the need to set up your AWS Batch infrastructure manually. Resources can also be automatically deleted when the compute environment is removed from Platform.
- Manually: this option lets Seqera use existing AWS Batch resources previously created.
Both options require specific IAM permissions to function correctly, as well as access to an S3 bucket or EFS/FSx file system to store intermediate Nextflow files.
S3 bucket creation
AWS S3 (Simple Storage Service) is a type of object storage. To access input and output files using Seqera products like Studios and Data Explorer create one or more S3 buckets. An S3 bucket can also be used to store intermediate results of your Nextflow pipelines, as an alternative to using EFS or FSx file systems.
Using EFS or FSx as work directory is incompatible with Studios.
- Navigate to the AWS S3 console.
- In the top right of the page, select the same region where you plan to create your AWS Batch compute environment.
- Select Create bucket.
- Enter a unique name for your bucket.
- Leave the rest of the options as default and select Create bucket.
S3 can be used by Nextflow for the storage of intermediate files. In production pipelines, this can amount to a lot of data. To reduce costs, consider using a retention policy when creating a bucket, such as automatically deleting intermediate files after 30 days. See the AWS documentation for more information.
EFS or FSx file system creation
AWS Elastic File System (EFS) and AWS FSx for Lustre are types of file storage that can be used as a Nextflow work directory to store intermediate files, as an alternative to using S3 buckets.
Using EFS or FSx as work directory is incompatible with Studios.
To use EFS or FSx as your Nextflow work directory, create an EFS or FSx file system in the same region where you plan to create your AWS Batch compute environment.
The creation of an EFS or FSx file system can be done automatically by Seqera when creating the AWS Batch compute environment, or manually by following the steps below. If you let Seqera create the file system automatically, it will also be deleted when the compute environment is removed from Platform, unless the "Dispose Resources" option is disabled in the advanced options.
Creating an EFS file system
To create a new EFS file system manually, visit the EFS console.
- Select Create file system.
- Optionally give it a name, then select the VPC where your AWS Batch compute environment will be created.
- Leave the rest of the options as default and select Create file system.
Creating an FSx file system
To create a new FSx for Lustre file system manually, visit the FSx console.
- Select Create file system.
- Select FSx for Lustre
- Follow the prompts to configure the file system according to your requirements, then select Next.
- Review the configuration and select Create file system.
Make sure the Lustre client is available in the AMIs used by your AWS Batch compute environment to allow mounting FSx file systems.
Required Platform IAM permissions
To create and launch pipelines, explore buckets with Data Explorer or run Studio sessions with the AWS Batch compute environment, an IAM user with specific permissions must be provided. Some permissions are mandatory for the compute environment to be created and function correctly, while others are optional and used for example to provide list of values to pick from in the Platform UI.
Permissions can be attached directly to an IAM user, or to an IAM role that the IAM user can assume when accessing AWS resources.
A permissive and broad policy with all the required permissions is provided here for a quick start. However, we recommend following the principle of least privilege and only granting the necessary permissions for your use case, as shown in the following sections.
Full permissive policy (for reference)
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "BatchEnvironmentManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"batch:CreateComputeEnvironment",
"batch:CreateJobQueue",
"batch:DeleteComputeEnvironment",
"batch:DeleteJobQueue",
"batch:UpdateComputeEnvironment",
"batch:UpdateJobQueue"
],
"Resource": [
"arn:aws:batch:*:*:compute-environment/TowerForge-*",
"arn:aws:batch:*:*:job-queue/TowerForge-*"
]
},
{
"Sid": "BatchEnvironmentListing",
"Effect": "Allow",
"Action": [
"batch:DescribeComputeEnvironments",
"batch:DescribeJobDefinitions",
"batch:DescribeJobQueues",
"batch:DescribeJobs"
],
"Resource": "*"
},
{
"Sid": "BatchJobsManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"batch:CancelJob",
"batch:RegisterJobDefinition",
"batch:SubmitJob",
"batch:TagResource",
"batch:TerminateJob"
],
"Resource": [
"arn:aws:batch:*:*:job-definition/*",
"arn:aws:batch:*:*:job-queue/TowerForge-*",
"arn:aws:batch:*:*:job/*"
]
},
{
"Sid": "LaunchTemplateManagement",
"Effect": "Allow",
"Action": [
"ec2:CreateLaunchTemplate",
"ec2:DeleteLaunchTemplate",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeLaunchTemplateVersions"
],
"Resource": "*"
},
{
"Sid": "PassRolesToBatchCanBeRestricted",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "*",
"Condition": {
"StringEquals": {
"iam:PassedToService": [
"batch.amazonaws.com",
"ec2.amazonaws.com"
]
}
}
},
{
"Sid": "CloudWatchLogsAccessCanBeRestricted",
"Effect": "Allow",
"Action": [
"logs:Describe*",
"logs:FilterLogEvents",
"logs:Get*",
"logs:List*",
"logs:StartQuery",
"logs:StopQuery",
"logs:TestMetricFilter"
],
"Resource": "*"
},
{
"Sid": "OptionalS3PlatformDataAccessCanBeRestricted",
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*",
"s3:PutObject"
],
"Resource": "*"
},
{
"Sid": "OptionalIAMManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"iam:AddRoleToInstanceProfile",
"iam:AttachRolePolicy",
"iam:CreateInstanceProfile",
"iam:CreateRole",
"iam:DeleteInstanceProfile",
"iam:DeleteRole",
"iam:DeleteRolePolicy",
"iam:DetachRolePolicy",
"iam:GetRole",
"iam:ListAttachedRolePolicies",
"iam:ListRolePolicies",
"iam:PutRolePolicy",
"iam:RemoveRoleFromInstanceProfile",
"iam:TagInstanceProfile",
"iam:TagRole"
],
"Resource": [
"arn:aws:iam::*:role/TowerForge-*",
"arn:aws:iam::*:instance-profile/TowerForge-*"
]
},
{
"Sid": "OptionalFetchOptimizedAMIMetadata",
"Effect": "Allow",
"Action": "ssm:GetParameters",
"Resource": "arn:aws:ssm:*:*:parameter/aws/service/ecs/*"
},
{
"Sid": "OptionalEC2MetadataDescribe",
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes",
"ec2:DescribeImages",
"ec2:DescribeInstanceTypeOfferings",
"ec2:DescribeInstanceTypes",
"ec2:DescribeKeyPairs",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs"
],
"Resource": "*"
},
{
"Sid": "OptionalFSXManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"fsx:CreateFileSystem",
"fsx:DeleteFileSystem",
"fsx:DescribeFileSystems",
"fsx:TagResource"
],
"Resource": "*"
},
{
"Sid": "OptionalEFSManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"elasticfilesystem:CreateFileSystem",
"elasticfilesystem:DeleteFileSystem",
"elasticfilesystem:CreateMountTarget",
"elasticfilesystem:DeleteMountTarget",
"elasticfilesystem:DescribeFileSystems",
"elasticfilesystem:DescribeMountTargets",
"elasticfilesystem:UpdateFileSystem",
"elasticfilesystem:PutLifecycleConfiguration",
"elasticfilesystem:TagResource"
],
"Resource": "*"
},
{
"Sid": "OptionalPipelineSecretsListing",
"Effect": "Allow",
"Action": "secretsmanager:ListSecrets",
"Resource": "*"
},
{
"Sid": "OptionalPipelineSecretsManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"secretsmanager:DescribeSecret",
"secretsmanager:DeleteSecret",
"secretsmanager:CreateSecret"
],
"Resource": "arn:aws:secretsmanager:*:*:secret:tower-*"
}
]
}
AWS Batch management
The first section of the policy allows Seqera to create, update and delete Batch compute environments ("CE"), job queues ("JQ") and jobs.
If you are required to use manually created CEs and JQs or prefer to manage their lifecycle yourself, you can remove the permissions to manipulate CEs and JQs from the policy. The minimum permissions required are:
batch:DescribeJobsto report job statusbatch:DescribeJobDefinitionsto list existing job definitionsbatch:RegisterJobDefinitionto create new job definitionsbatch:CancelJobto cancel jobsbatch:SubmitJobto submit jobsbatch:TagResourceto tag jobsbatch:TerminateJobto terminate jobs
You can use batch:DescribeJobQueues to list the existing job queues in a drop-down menu but it's not required if you're specifying manually created job queues.
However, it is required when you let Seqera create and manage job queues automatically (using the Forge tool). In this case, the batch:DescribeComputeEnvironments permission must also be added.
You can also restrict permissions based on resource tags. These are defined by users when they set up a pipeline in Platform.
{
"Sid": "BatchEnvironmentListing",
"Effect": "Allow",
"Action": [
"batch:DescribeJobDefinitions",
"batch:DescribeJobs"
],
"Resource": "*"
},
{
"Sid": "BatchJobsManagement",
"Effect": "Allow",
"Action": [
"batch:CancelJob",
"batch:RegisterJobDefinition",
"batch:SubmitJob",
"batch:TagResource",
"batch:TerminateJob"
],
"Resource": [
"arn:aws:batch:<REGION>:<ACCOUNT_ID>:job-queue/MyCustomJQ",
"arn:aws:batch:<REGION>:<ACCOUNT_ID>:job-definition/*",
"arn:aws:batch:<REGION>:<ACCOUNT_ID>:job/*"
],
"Condition": {
"StringEqualsIfExists": {
"aws:ResourceTag/MyCustomTag": "MyCustomValue"
}
}
}
Restricting the batch actions using resource tags requires that you set the appropriate tags on each Seqera pipeline when configuring it in Platform. Forgetting to set the tag will cause the pipeline to fail to run.
The job definition and job name resources cannot be restricted to specific names, as Seqera creates job definitions and jobs with dynamic names. Therefore, the wildcard * must be used in the name of these resources. In addition, batch:SubmitJob requires permission on both job definitions and job queues, so make sure to include both ARNs in the Resource array.
If you prefer to let Seqera manage Batch resources for you, you can still restrict the permissions to specific resources in your account ID and region; you can also restrict permissions based on Resource tag, as shown with the Conditions in the example above.
The quick start policy is expecting CE and JQ names automatically created by Seqera to start with the TowerForge- prefix, which is the default prefix used by Platform Cloud resources and can't be customized.
Launch template management
Seqera requires the ability to create and manage EC2 launch templates using optimized AMIs identified via AWS Systems Manager (SSM).
AWS does not support restricting IAM permissions on EC2 launch templates based on specific resource names or tags. As a result, permission to operate on any resource * must be granted.
Pass role to Batch
The iam:PassRole permission allows Seqera to pass execution IAM roles to AWS Batch to run Nextflow pipelines.
Permissions can be restricted to only allow passing the manually created roles or the roles created by Seqera automatically with the default prefix TowerForge- to the AWS Batch and EC2 services, in a specific account:
{
"Sid": "PassRolesToBatch",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::<ACCOUNT_ID>:role/TowerForge-*",
"Condition": {
"StringEquals": {
"iam:PassedToService": [
"batch.amazonaws.com",
"ec2.amazonaws.com"
]
}
}
}
CloudWatch logs access
Seqera requires access to CloudWatch logs to display relevant log data in the web interface.
The policy can be scoped down to limit access to the specific log group defined on the compute environment in a specific account and region:
{
"Sid": "CloudWatchLogsAccess",
"Effect": "Allow",
"Action": [
"logs:Describe*",
"logs:FilterLogEvents",
"logs:Get*",
"logs:List*",
"logs:StartQuery",
"logs:StopQuery",
"logs:TestMetricFilter"
],
"Resource": "arn:aws:logs:<REGION>:<ACCOUNT_ID>:log-group:/aws/batch/job/*"
}
S3 access (optional)
Seqera automatically attempts to fetch a list of S3 buckets available in the AWS account connected to Platform, to provide them in a drop-down menu to be used as Nextflow working directory, and make the compute environment creation smoother. This feature is optional, and users can type the bucket name manually when setting up a compute environment. To allow Seqera to fetch the list of buckets in the account, the s3:ListAllMyBuckets action can be added, and it must have the Resource field set to *, as shown in the generic policy at the beginning of this document.
Seqera offers several products to manipulate data on AWS S3 buckets, such as Studios and Data Explorer; if these features are not used the related permissions can be omitted.
The IAM policy can be scoped down to only allow limited read/write permissions in certain S3 buckets used by Studios/Data Explorer. In addition, the policy must include permission to check the region and list the content of the S3 bucket used as Nextflow work directory. We also recommend granting the s3:GetObject permission on the work directory path to fetch Nextflow log files.
If you opted to create a separate S3 bucket only for Nextflow work directories, there is no need for the IAM user to have read/write access to it. If Seqera is allowed to manage resources (using Batch Forge) the IAM roles automatically created will have the necessary permissions.
If you set up the compute environment manually, you can create the required IAM roles with the necessary permissions as detailed in the manual AWS Batch setup documentation.
{
"Sid": "S3CheckBucketWorkDirectory",
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::example-bucket-used-as-work-directory"
]
},
{
"Sid": "S3ReadOnlyNextflowLogFiles",
"Effect": "Allow",
"Action": [
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::example-bucket-used-as-work-directory/path/to/work/directory/*"
]
},
{
"Sid": "S3ReadWriteBucketsForStudiosDataExplorer",
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::example-bucket-read-write-studios",
"arn:aws:s3:::example-bucket-read-write-studios/*",
"arn:aws:s3:::example-bucket-read-write-data-explorer",
"arn:aws:s3:::example-bucket-read-write-data-explorer/*"
]
}
IAM roles for AWS Batch (optional)
Seqera can automatically create the IAM roles needed to interact with AWS Batch and other AWS services. You can opt out of this behavior by creating the required IAM roles manually and providing their ARNs during compute environment creation in Platform: refer to the documentation for more details on how to manually set up IAM roles.
To allow Seqera to create IAM roles but restrict it to your specific account and the default IAM role prefix, use the following statement:
{
"Sid": "IAMRoleAndProfileManagement",
"Effect": "Allow",
"Action": [
"iam:AddRoleToInstanceProfile",
"iam:AttachRolePolicy",
"iam:CreateInstanceProfile",
"iam:CreateRole",
"iam:DeleteInstanceProfile",
"iam:DeleteRole",
"iam:DeleteRolePolicy",
"iam:DetachRolePolicy",
"iam:GetRole",
"iam:ListAttachedRolePolicies",
"iam:ListRolePolicies",
"iam:PutRolePolicy",
"iam:RemoveRoleFromInstanceProfile",
"iam:TagInstanceProfile",
"iam:TagRole"
],
"Resource": [
"arn:aws:iam::<ACCOUNT_ID>:role/TowerForge-*"
"arn:aws:iam::<ACCOUNT_ID>:instance-profile/TowerForge-*"
]
}
The quick start policy is expecting role names automatically created by Seqera to start with the TowerForge- prefix, which is the default prefix used by Platform Cloud resources and can't be customized.
AWS Systems Manager (optional)
Seqera Platform can interact with AWS Systems Manager (SSM) to identify ECS Optimized AMIs for pipeline execution. This permission is optional, meaning that a custom AMI ID can be provided at compute environment creation, removing the need for this permission.
EC2 describe permissions (optional)
Seqera can interact with EC2 to retrieve information about existing AWS resources in your account, including VPCs, subnets, and security groups. This data is used to populate dropdown menus in the Platform UI when creating new compute environments. While these permissions are optional, they are recommended to enhance the user experience. Without these permissions, resource ARNs need to be manually entered in the interface by the user.
AWS does not support restricting IAM permissions on EC2 Describe actions based on specific resource names or tags. As a result, permission to operate on any resource * must be granted.
FSx file systems (optional)
Seqera can manage AWS FSx file systems, if needed by the pipelines.
This section of the policy is optional and can be omitted if FSx file systems are not used by your pipelines. The describe actions cannot be restricted to specific resources, so permission to operate on any resource * must be granted. The management actions can be restricted to specific resources, like in the example below.
{
"Sid": "FSxDescribe",
"Effect": "Allow",
"Action": [
"fsx:DescribeFileSystems"
],
"Resource": "*"
},
{
"Sid": "FSxManagement",
"Effect": "Allow",
"Action": [
"fsx:CreateFileSystem",
"fsx:DeleteFileSystem",
"fsx:TagResource"
],
"Resource": "arn:aws:fsx:<REGION>:<ACCOUNT_ID>:file-system/MyManualFSx"
}
EFS file systems (optional)
Seqera can manage AWS EFS file systems, if needed by the pipelines.
This section of the policy is optional and can be omitted if EFS file systems are not used by your pipelines. The describe actions cannot be restricted to specific resources, so permission to operate on any resource * must be granted. The management actions can be restricted to specific resources, like in the example below.
{
"Sid": "EFSDescribe",
"Effect": "Allow",
"Action": [
"elasticfilesystem:DescribeFileSystems",
"elasticfilesystem:DescribeMountTargets"
],
"Resource": "*"
},
{
"Sid": "EFSManagement",
"Effect": "Allow",
"Action": [
"elasticfilesystem:CreateFileSystem",
"elasticfilesystem:DeleteFileSystem",
"elasticfilesystem:CreateMountTarget",
"elasticfilesystem:DeleteMountTarget",
"elasticfilesystem:UpdateFileSystem",
"elasticfilesystem:PutLifecycleConfiguration",
"elasticfilesystem:TagResource"
],
"Resource": "arn:aws:elasticfilesystem:<REGION>:<ACCOUNT_ID>:file-system/MyManualEFS"
}
Pipeline secrets (optional)
Seqera can synchronize pipeline secrets defined on the Platform workspace with AWS Secrets Manager, which requires additional permissions on the IAM user. If you do not plan to use pipeline secrets, you can omit this section of the policy.
The listing of secrets cannot be restricted, but the management actions can be restricted to only allow managing secrets in a specific account and region, which must be the same region where the pipeline runs. Note that Seqera only creates secrets with the tower- prefix.
{
"Sid": "PipelineSecretsListing",
"Effect": "Allow",
"Action": "secretsmanager:ListSecrets",
"Resource": "*"
},
{
"Sid": "PipelineSecretsManagementCanBeRestricted",
"Effect": "Allow",
"Action": [
"secretsmanager:DescribeSecret",
"secretsmanager:DeleteSecret",
"secretsmanager:CreateSecret"
],
"Resource": "arn:aws:secretsmanager:<REGION>:<ACCOUNT_ID>:secret:tower-*"
}
Additional steps required to use secrets in a pipeline
To successfully use pipeline secrets, the IAM roles manually created must follow the steps detailed in the documentation.
Create the IAM policy
The policy above must be created in the AWS account where the AWS Batch resources need to be created.
- Open the AWS IAM console in the account where you want to create the AWS Batch resources.
- From the left navigation menu, select Policies under Access management.
- Select Create policy.
- On the Policy editor section, select the JSON tab.
- Following the instructions detailed in the IAM permissions breakdown section replace the default text in the policy editor area under the JSON tab with a policy adapted to your use case, then select Next.
- Enter a name and description for the policy on the Review and create page, then select Create policy.
IAM user creation
Seqera requires an Identity and Access Management (IAM) User to create and manage AWS Batch resources in your AWS account. We recommend creating a separate IAM policy rather an IAM User inline policy, as the latter only allows 2048 characters, which may not be sufficient for all the required permissions.
In certain scenarios, for example when multiple users need to access the same AWS account and provision AWS Batch resources, an IAM role with the required permissions can be created instead, and the IAM user can assume that role when accessing AWS resources, as detailed in the IAM role creation (optional) section.
Depending whether you choose to let Seqera automatically create the required AWS Batch resources in your account, or prefer to set them up manually, the IAM user must have specific permissions as detailed in the Required Platform IAM permissions section. Alternatively, you can create an IAM role with the required permissions and allow the IAM user to assume that role when accessing AWS resources, as detailed in the IAM role creation (optional) section.