@@ -166,6 +166,7 @@ async def launch_instances(
166166 _logger .debug (
167167 "Attempting to launch instances in subnet %s" , subnet_id
168168 )
169+
169170 instances = await self .client .run_instances (
170171 ImageId = instance_config .ami_id ,
171172 MinCount = min_number_of_instances ,
@@ -199,6 +200,16 @@ async def launch_instances(
199200 # If we get here, the launch succeeded
200201 break
201202 except botocore .exceptions .ClientError as exc :
203+ # AI says run_instances may raise the following errors:
204+ # InsufficientInstanceCapacity, when a subnet does not have enough capacity
205+ # InstanceLimitExceeded, when the AWS account has reached its limit of instances for this region
206+ # InvalidAMIID.NotFound, when the AMI ID does not exist
207+ # InvalidSubnetID.NotFound, when the subnet does not exist
208+ # InvalidGroupId.NotFound, when a security group does not exist
209+ # InvalidKeyPair.NotFound, when the key pair does not exist
210+ # UnauthorizedOperation, when the credentials do not have permissions to launch instances
211+ # InvalidInstanceType, when the instance type is not valid
212+
202213 error_code = exc .response .get ("Error" , {}).get ("Code" )
203214 if error_code == "InsufficientInstanceCapacity" :
204215 _logger .warning (
0 commit comments