Getting Started - Fargate - AWS Batch

Getting Started - Fargate

AWS Fargate launches and scales the compute to closely match the resource requirements that you specify for the container. With Fargate, you don't need to over-provision or pay for additional servers. For more information, see Fargate.

Create a compute environment

To create a compute environment for a Fargate orchestration, do the following:

  1. Open the AWS Batch console first-run wizard.

  2. For Select orchestration type, choose Fargate.

  3. Choose Next.

  4. In the Compute environment configuration section for Name, specify a unique name for your compute environment. The name can be up to 128 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  5. (Optional) A tag is a label that's assigned to a resource. To add a tag, expand Tags, then choose Add tag. Enter a key-value pair, and then choose Add tag again.

    Important

    If you choose Add tag, you must enter a key-value pair and choose Add tag again or choose Remove tag.

  6. (Optional) In the Instance configuration section for Use Fargate Spot capacity, turn on Enable using Spot instances.

  7. For Maximum vCPUs, enter the maximum number of vCPUs that the instance can use.

  8. In the Network configuration section:

    1. For Virtual Private Cloud (VPC) ID, choose an Amazon VPC.

    2. For Subnets, the subnets for your AWS account are listed. If you want to create a custom set of subnets, choose Clear subnets, and then choose the subnets that you want.

      Important

      Compute resources must communicate with the Amazon ECS VPC endpoint through a VPC endpoint or multiple public IP address. For more information, see Amazon ECS interface VPC endpoints (AWS PrivateLink). If your instance doesn't have a VPC endpoint configured or a public IP address, you can use network address translation (NAT). For more information about NAT, see NAT gateways and Creating a virtual private cloud .

    3. For Security groups, choose the Amazon EC2 security groups that you want to associate with the instance. If you want to create a custom set of security groups, choose Clear security groups. Then, choose the security groups that you want.

  9. Choose Next.

Create a job queue

A job queue stores your submitted jobs until the AWS Batch Scheduler runs the job on a resource in your compute environment. To create a job queue:

To create a job queue for a Fargate orchestration, do the following:

  1. In the Job queue configuration section for Name, specify a unique name for your compute environment. The name can be up to 128 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  2. For Priority, enter an integer between 0 and 100 for the job queue.

    Important

    Higher integer values are assigned a higher priority by the AWS Batch Scheduler.

  3. Choose Next.

Create a job definition

To create the job definition:

  1. In the General configuration section:

    1. For Name, enter a custom job definition name.

      In the General configuration section for Name, specify a unique name for your compute environment. The name can be up to 128 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

    2. (Optional) For Execution timeout, enter the amount of time (in seconds) that an unfinished job terminates after.

      Important

      The minimum timeout is 60 seconds.

    3. (Optional) A tag is a label that's assigned to a resource. To add a tag, expand Tags, then choose Add tag. Enter a key-value pair, and then choose Add tag again.

      Important

      If you choose Add tag, you must enter a key-value pair and choose Add tag again or choose Remove tag.

    4. (Optional) Turn on Propagate tags to propagate tags to the Amazon Elastic Container Service task.

  2. In the Fargate platform configuration section:

    1. (Optional) For Fargate platform version, enter the specific runtime environment that you want.

    2. For Runtime platform, select a LINUX or Windows.

    3. (Windows only) For Operating System Family, select an operating system.

    4. For CPU architecture, select the CPU architecture that you want.

    5. (Optional) Turn on Assign public IP to assign a public IP address.

    6. For Ephemeral storage, enter the amount of ephemeral storage that you want.

      Note

      By default, 20 GiB of ephemeral storage is used. To use additional ephemeral storage, enter a value between 21 GiB and 100 GiB.

    7. For Execution role, choose a task execution role that lets Amazon Elastic Container Service (Amazon ECS) agents make AWS calls on your behalf. For example, you can choose ecsTaskExecutionRole.

  3. In the Container configuration section:

    1. For Image, enter the name of the image that's used to launch the container. By default, all the images in the Docker Hub registry are available. You can also specify other repositories in repository-url/image:tag format. The parameter can be up to 255 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), underscores (_), colons (:), periods (.), forward slashes (/), and number signs (#). The parameter maps to Image in the Create a container section of the Docker Remote API and the IMAGE parameter of docker run.

      Note

      Docker image architecture must match the processor architecture of the compute resources that they're scheduled on. For example, Arm based Docker images can only run on Arm based compute resources.

      • Images in Amazon ECR Public repositories use the full registry/repository[:tag] or registry/repository[@digest] naming conventions (for example, public.ecr.aws/registry_alias/my-web-app:latest).

      • Images in Amazon ECR repositories use the full registry/repository:tag naming convention (for example, aws_account_id.dkr.ecr.region.amazonaws.com/my-web-app:latest).

      • Images in official repositories on Docker Hub use a single name (for example, ubuntu or mongo).

      • Images in other repositories on Docker Hub are qualified with an organization name (for example, amazon/amazon-ecs-agent).

      • Images in other online repositories are qualified further by a domain name (for example, quay.io/assemblyline/ubuntu).

    2. For Command, specify the command to pass to the container. This parameter maps to Cmd in the Create a container section of the Docker Remote API and the COMMAND parameter to docker run. For more information about the Docker CMD parameter, see https://docs.docker.com/engine/reference/builder/#cmd.

      Note

      You can use parameter substitution default values and placeholders in your command. For more information, see Parameters.

      Tip

      Choose Info to review Bash and JSON code examples.

    3. (Optional) You can add parameters to the job definition as key-value mappings to override the job definition defaults. To add a parameter:

      1. For Parameters, choose Add parameter. Enter a key-value pair and then choose Add parameter again.

        Important

        If you choose Add parameter, you must configure at least one parameter or choose Remove parameter.

    4. (Optional) In the Environment configuration section for Job role configuration, choose an IAM role that provides permission to use the AWS APIs.

    5. In the Environment configuration section for vCPUs, specify the number of vCPUs to reserve for the container. This parameter maps to CpuShares in the Create a container section of the Docker Remote API and the --cpu-shares option to docker run. Each vCPU is equivalent to 1,024 CPU shares.

    6. For Memory, specify the hard limit (in MiB) of memory to present to the job container. If your container attempts to exceed the memory specified here, the container is stopped. This parameter maps to Memory in the Create a container section of the Docker Remote API and the --memory option to docker run.

    7. (Optional) For Environment variables, choose Add environment variables to add environment variables to pass to the container. This parameter maps to Env in the Create a container section of the Docker Remote API and the --env option to docker run.

  4. Choose Next.

Create a job

To create a Fargate job, do the following:

  1. In the Job configuration section for Name, specify a unique name for the job. The name can be up to 128 characters in length. It can contain uppercase and lowercase letters, numbers, hyphens (-), and underscores (_).

  2. Choose Next.

Review and create

On the Review and create page, review the configuration steps. If you need to make changes, choose Edit. When you're finished, choose Create resources.