Getting started with Amazon EC2 orchestration using the Wizard - Amazon Batch
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Getting started with Amazon EC2 orchestration using the Wizard

Amazon Elastic Compute Cloud (Amazon EC2) provides scalable computing capacity in the Amazon Web Services Cloud. Using Amazon EC2 eliminates your need to invest in hardware up front, so you can develop and deploy applications faster.

You can use Amazon EC2 to launch as many or as few virtual servers as you need, configure security and networking, and manage storage. Amazon EC2 enables you to scale up or down to handle changes in requirements or spikes in popularity, reducing your need to forecast traffic.

Overview

This tutorial demonstrates how to setup Amazon Batch with the Wizard to configure Amazon EC2 and run Hello World.

Intended Audience

This tutorial is designed for system administrators and developers responsible for setting up, testing, and deploying Amazon Batch.

Features Used

This tutorial shows you how to use the Amazon Batch console wizard to:

  • Create and configure an Amazon EC2 compute environment

  • Create a job queue.

  • Create a job definition

  • Create and submit a job to run

  • View the output of the job in CloudWatch

Time Required

It should take about 10–15 minutes to complete this tutorial.

Regional Restrictions

There are no country or regional restrictions associated with using this solution.

Resource Usage Costs

There's no charge for creating an Amazon account. However, by implementing this solution, you might incur some or all of the costs that are listed in the following table.

Description Cost (US dollars)
Amazon EC2 instance You pay for each Amazon EC2 instance that is created. For more information about pricing, see Amazon EC2 Pricing.

Prerequisites

Before you begin:

Step 1: Create a compute environment

Important

To get started as simply and quickly as possible, this tutorial includes steps with default settings. Before creating for production use, we recommend that you familiarize yourself with all settings and deploy with the settings that meet your requirements.

To create a compute environment for an Amazon EC2 orchestration, do the following:

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

  2. For Configure job and orchestration type, choose Amazon Elastic Compute Cloud(Amazon EC2).

  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. For Instance role, choose an existing instance role that has the required IAM permissions attached. This instance role allows the Amazon ECS container instances in your compute environment to make calls to the required Amazon API operations. For more information, see Amazon ECS instance role.

    The default name of the Instance role is ecsInstanceRole.

  6. For Instance configuration you can leave the default settings.

  7. For Network configuration use your default VPN for the Amazon Web Services Region.

  8. Choose Next.

Step 2: Create a job queue

A job queue stores your submitted jobs until the Amazon Batch Scheduler runs the job on a resource in your compute environment. For more information, see Job queues

To create a job queue for an Amazon EC2 orchestration, do the following:

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

  2. For all other configuration options you can leave the default value.

  3. Choose Next.

Step 3: Create a job definition

Amazon Batch job definitions specify how jobs are to be run. Even though each job must reference a job definition, many of the parameters that are specified in the job definition can be overridden at runtime.

To create the job definition:

  1. For Create a job definition

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

    2. For Command - optional you can change hello world to a custom message or leave it as is.

  2. For all other configuration options you can leave the default value.

  3. Choose Next.

Step 4: Create a job

To create a 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. For all other configuration options you can leave the default value.

  3. Choose Next.

Step 5: 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.

  1. For Review and create choose Create resources.

  2. A window opens as Amazon Batch starts to allocate your resources. Once complete choose Go to dashboard. On the dashboard you should see all of your allocated resources and that the job is in the Runnable state. Your job is scheduled to run and should complete in 2–3 minuets.

Step 6: View the Job's output

To view the Job's output, do the following:

  1. In the navigation pane choose Jobs.

  2. In the Job queue drop down choose the Job queue you created for the tutorial.

  3. The Jobs table lists all of your Jobs and what their current status is. Once the Job's Status is Succeeded choose the Name of the Job to view the Job's details.

  4. In the Details pane choose Log stream name. The CloudWatch console for the Job will open and there should be one event with the Message of hello world or your custom message.

Step 7: Clean up your tutorial resources

You are charged for the Amazon EC2 instance while it is enabled. You can delete the instance to stop incurring charges.

To delete the resources you created, do the following:

  1. In the navigation pane choose Job queue.

  2. In the Job queue table choose the Job queue you created for the tutorial.

  3. Choose Disable. Once the Job queue State is Disabled you can choose Delete.

  4. Once the Job queue is deleted, in the navigation pane choose Compute environments.

  5. Choose the compute environment you created for this tutorial and then choose Disable. It may take 1–2 minuets for the compute environment to complete being disabled.

  6. Once the compute environment’s State is Disabled, choose Delete. It may take 1–2 minuets for the compute environment to be deleted.

Additional resources

After you complete the tutorial, you might want to explore the following topics::