Skip to content

Instantly share code, notes, and snippets.

@ensean
Created March 10, 2024 15:26
Show Gist options
  • Save ensean/41dd14bca948bb1df44ca0bfca26b3e0 to your computer and use it in GitHub Desktop.
Save ensean/41dd14bca948bb1df44ca0bfca26b3e0 to your computer and use it in GitHub Desktop.
lambda modify aurora serverless acu
import json
import boto3
client = boto3.client('rds')
def modify_acu(cluster_id, min_acu, max_acu):
resp = client.modify_db_cluster(
DBClusterIdentifier=cluster_id,
ApplyImmediately=True,
ServerlessV2ScalingConfiguration={
'MinCapacity': min_acu,
'MaxCapacity': max_acu
}
)
return resp
def lambda_handler(event, context):
cluster_id = event.get('cluster_id', None)
min_acu = event.get('min_acu', 0)
max_acu = event.get('max_acu', 0)
if cluster_id is None or min_acu == 0 or max_acu == 0:
return {
'statusCode': 401,
'body': json.dumps('Parameter error.')
}
resp = modify_acu(cluster_id, min_acu, max_acu)
return {
'statusCode': 200,
'body': json.dumps('Cluster updated')
}
@ensean
Copy link
Author

ensean commented May 6, 2024

通过 boto3 SDK 配置 Aurora Serverless V2 的 ACU,实现主动扩容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment