g. Set up a Job Definition

In this step, you set up a template used for your jobs, known as a job definition. A job definition is not required, but a good practice to use so that you can version how your jobs are launched. For more information about job definitions, see Job Definitions.

  1. In the AWS Batch Dashboard, choose Job definitions from the left pane, then Create. Ignore the Loading resources message in the grid. AWS Batch
  2. Type a Job definition name.
  3. For Job attempts, type 5. This option specifies the number of attempts before declaring a job as failed.
  4. For Execution timeout, type 500. This option specifies the time between attempts in seconds. AWS Batch
  5. For Container Image, enter the repositoryUri generated when you created the ECR repository. If you do not know the URI, use the following command in your terminal.

    aws ecr describe-repositories --repository-names carla-av-demo --output text --query 'repositories[0].[repositoryUri]'
  6. Clear out the contents of the Command text box, as we don’t want to run any command when your job runs.

  7. For vCPUs type 4.

  8. For Memory (MiB) type 2048.

  9. Leave the value as blank for Number of GPUs field. AWS Batch

  10. Expand the Additional configuration section.

  11. For Job role and Execution role, choose the role previously defined for ECS tasks in b. Workshop Initial Setup. If you do not know the name of the job role, use the following command in your terminal to validate. Do not select any values for Volumes, Mount points, and Ulimits.

    echo "ECS Job Role: $(aws cloudformation describe-stacks --stack-name PrepAVWorkshop --output text --query 'Stacks[0].Outputs[?OutputKey == `ECSTaskPolicytoS3`].OutputValue')"
    echo "ECS Job Exceution Role: $(aws cloudformation describe-stacks --stack-name PrepAVWorkshop --output text --query 'Stacks[0].Outputs[?OutputKey == `ECSJobExecutionRole`].OutputValue')"

AWS Batch 11. Skip to the Environment variables section. 12. Choose Add environment variable. This environmental variable will tell the application running in your container where to export data. 13. For Name, type EXPORT_S3_BUCKET_URL such as s3://BUCKET-NAME. For Value, choose the bucket you previously created. To find the name of the S3 bucket, run the following command in your terminal or view the S3 Dashboard in your account.

echo "S3 Output Bucket: $(aws cloudformation describe-stacks --stack-name PrepAVWorkshop --output text --query 'Stacks[0].Outputs[?OutputKey == `OutputBucket`].OutputValue')"

AWS Batch 14. Scroll towards the bottom of the page and Choose Create. AWS Batch 15. Once the Job definition is ready, it will be visible under Job definitions grid. Make sure Status is ACTIVE. AWS Batch

Next, take a closer look at compute environment, job queue, and job definition you created.