Skip to content

Commit ed8f68b

Browse files
Add EC2 API retry config to handle RequestLimitExceeded throttling
Configure botocore with 15 total retry attempts using standard mode to handle EC2 RunInstances API throttling when multiple VPUs launch simultaneously. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 912bb77 commit ed8f68b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

infra/aws/terraform/modules/orchestration/lambdas/start_ami/lambda_function.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import boto3
22
import botocore
3+
from botocore.config import Config
34
import time, os, json
45

6+
# Configure retry for EC2 API throttling (RequestLimitExceeded)
7+
# https://boto3.amazonaws.com/v1/documentation/api/latest/guide/retries.html
8+
retry_config = Config(
9+
retries={
10+
'total_max_attempts': 15,
11+
'mode': 'standard'
12+
}
13+
)
14+
515
global client_ec2
6-
client_ec2 = boto3.client('ec2',region_name=os.environ['AWS_REGION'])
16+
client_ec2 = boto3.client('ec2', region_name=os.environ['AWS_REGION'], config=retry_config)
717

818
REGION_NAME_MAP = {
919
"us-east-1": "US East (N. Virginia)",

0 commit comments

Comments
 (0)