将自动缩放策略应用于 DynamoDB 时出现 ObjectNotFoundException table
ObjectNotFoundException when applying autoscaling policy to DynamoDB table
我是 运行 使用 boto3 SDK 的 lambda 函数,以便将自动缩放策略添加到许多 dynamoDB 表和索引中,但是它一直抛出此错误:
An error occurred (ObjectNotFoundException) when calling the PutScalingPolicy operation: No scalable target registered for service namespace: dynamodb, resource ID: table/tableName, scalable dimension: dynamodb:table:ReadCapacityUnits: ObjectNotFoundException
相关代码在这里:
def set_scaling_policy(resource_type, capacity_type, resource_id):
dbClient = boto3.client('application-autoscaling')
response = dbClient.put_scaling_policy(
PolicyName= 'dynamoDBScaling',
ServiceNamespace= 'dynamodb',
ResourceId= resource_id,
ScalableDimension= 'dynamodb:{0}:{1}CapacityUnits'.format(resource_type,capacity_type),
PolicyType='TargetTrackingScaling',
TargetTrackingScalingPolicyConfiguration={
'TargetValue': 50.0,
'PredefinedMetricSpecification': {
'PredefinedMetricType': 'DynamoDB{0}CapacityUtilization'.format(capacity_type)
}
}
)
(resource_type 是 'table' 或 'index';capacity_type 是 'Read' 或 'Write')
我考虑过的一些解决方案:
修复权限 - 它之前有一些权限问题,我给了它 AmazonDynamoDBFullAccess,它似乎已经解决了所有问题。另外,如果它没有访问权限
,它可能会抛出一个不同的错误
参数格式 - 根据 API here,这一切似乎都是正确的。我尝试过使用完整的 ARN 而不是 table/tableName、仅使用表名等变体
检查 tableName 是否确实存在 - 它确实存在,我可以通过 AWS 控制台添加和删除扩展策略就好了
put_scaling_policy
You cannot create a scaling policy until you register the scalable
target using RegisterScalableTarget
register_scalable_target
Registers or updates a scalable target. A scalable target is a
resource that Application Auto Scaling can scale out or scale in.
After you have registered a scalable target, you can use this
operation to update the minimum and maximum values for its scalable
dimension.
我是 运行 使用 boto3 SDK 的 lambda 函数,以便将自动缩放策略添加到许多 dynamoDB 表和索引中,但是它一直抛出此错误:
An error occurred (ObjectNotFoundException) when calling the PutScalingPolicy operation: No scalable target registered for service namespace: dynamodb, resource ID: table/tableName, scalable dimension: dynamodb:table:ReadCapacityUnits: ObjectNotFoundException
相关代码在这里:
def set_scaling_policy(resource_type, capacity_type, resource_id):
dbClient = boto3.client('application-autoscaling')
response = dbClient.put_scaling_policy(
PolicyName= 'dynamoDBScaling',
ServiceNamespace= 'dynamodb',
ResourceId= resource_id,
ScalableDimension= 'dynamodb:{0}:{1}CapacityUnits'.format(resource_type,capacity_type),
PolicyType='TargetTrackingScaling',
TargetTrackingScalingPolicyConfiguration={
'TargetValue': 50.0,
'PredefinedMetricSpecification': {
'PredefinedMetricType': 'DynamoDB{0}CapacityUtilization'.format(capacity_type)
}
}
)
(resource_type 是 'table' 或 'index';capacity_type 是 'Read' 或 'Write')
我考虑过的一些解决方案:
修复权限 - 它之前有一些权限问题,我给了它 AmazonDynamoDBFullAccess,它似乎已经解决了所有问题。另外,如果它没有访问权限
,它可能会抛出一个不同的错误
参数格式 - 根据 API here,这一切似乎都是正确的。我尝试过使用完整的 ARN 而不是 table/tableName、仅使用表名等变体
检查 tableName 是否确实存在 - 它确实存在,我可以通过 AWS 控制台添加和删除扩展策略就好了
put_scaling_policy
You cannot create a scaling policy until you register the scalable target using RegisterScalableTarget
register_scalable_target
Registers or updates a scalable target. A scalable target is a resource that Application Auto Scaling can scale out or scale in. After you have registered a scalable target, you can use this operation to update the minimum and maximum values for its scalable dimension.