# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # Permission is hereby granted, free of charge, to any person obtaining a copy of this # software and associated documentation files (the "Software"), to deal in the Software # without restriction, including without limitation the rights to use, copy, modify, # merge, publish, distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, # INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A # PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AWSTemplateFormatVersion: '2010-09-09' Description: > Setup a Job Queue and an EC2 Compute Environment on AWS Batch. Author: maxhaws@ Parameters: InstanceType: Description: EC2 instance type Type: List Default: "c5, m5, r5" ConstraintDescription: must be a valid EC2 instance type. Minvcpus: Type: Number Default: 0 Description: Minimum number of vCPUs per Compute Environment Maxvcpus: Type: Number Default: 256 Description: Maximum number of vCPUs per Compute Environment SubnetIds: Type: List Description: Subnet Id SecurityGroupId: Type: AWS::EC2::SecurityGroup::Id Description: Security Group Id ############################ ## AWS Batch Infrastructure Resources: BatchECSCE: Type: AWS::Batch::ComputeEnvironment Properties: Type: MANAGED ComputeResources: AllocationStrategy: BEST_FIT_PROGRESSIVE MinvCpus: !Ref Minvcpus MaxvCpus: !Ref Maxvcpus SecurityGroupIds: - !Ref SecurityGroupId Subnets: !Ref SubnetIds Type: EC2 InstanceRole: "ecsInstanceRole" InstanceTypes: !Ref InstanceType State: ENABLED BatchJobQueue: Type: AWS::Batch::JobQueue Properties: JobQueueName: !Sub 'jq-${AWS::StackName}' ComputeEnvironmentOrder: - ComputeEnvironment: !Ref BatchECSCE Order: 1 Priority: 1 State: "ENABLED" ############ ## Outputs Outputs: ComputeEnvironment: Value: !Ref BatchECSCE JobQueue: Value: !Ref BatchJobQueue