e. Set up Compute Environment
In this step, you set up an AWS Batch Compute Environment using the AWS Management Console.
Compute environments can be seen as computational clusters. They can consist of one or several instance kinds or just the number of cores you want in the environment. For more information on the compute environments, see Compute Environments.
- In the AWS Management Console, in the search bar, search for and choose Batch.
- In the left pane, choose Compute environments, then choose Create compute environment or Create.
- Under Compute environment configuration, choose Managed for Compute environment type. This option allows AWS Batch manage the automatic scaling of EC2 resources for you.
- Type a Compute environment name.
- Check Enable compute environment. This option enables the AWS Batch environment when it’s ready.
- Expand Additional settings: service role, instance role, EC2 key pair section.
- For Service role, choose AWSBatchServiceRole. The role allows the AWS Batch service to make calls to the required AWS API operations on your behalf. For more information, see AWS Batch Service IAM Role.
- For Instance role, choose Create a new role. This instance profile allows the Amazon ECS container instances that are created for your compute environment to make calls to the required AWS API operations on your behalf. For more information, see Amazon ECS Instance Role. If you choose to create a new instance profile, the required role (ecsInstanceRole) is created for you.
- Leave the EC2 key pair field as is, do not provide a key pair.
- Under Instance configuration, choose On-demand for Provisioning model. This option allows AWS Batch manage the automatic scaling of EC2 resources for you.
- Leave the default value of 0 for Minimum vCPUs.
- For Maximum vCPUs type 16 (which allows you to use up to 4 instances).
- Leave the default value of 0 for Desired vCPUs - *optional*.
- For Allowed instance types, remove optimal and choose g3s.xlarge.
- Select BEST_FIT for Allocation strategy
- Expand Additional settings: launch template, user specified AMI section.
- Check Enable for User-specified AMI ID.
- Type the AMI ID generated with Packer in Step c. Build Your AMI with Packer.
- Under Networking, for VPI ID, choose the Default VPC.
- Select all the subnets.
- For Security groups, select the default.
- For Placement groups - *optional*, leave it empty.
- Under EC2 tags - *optional*, Add a Tag called Name and for Value, type CARLA Batch as a name for your instances created with Batch. You can add additional tags if you want.
- Choose Create compute environment to build your new compute environment.
- Once the environment is ready, it will be visible under Compute environments section. Make sure Status is VALID and State is ENABLED.
At this point, you have done the hard part! Continue to set up a job queue.