title: ObjectNotFoundException when applying autoscaling policy to DynamoDB table
body: <p>I'm running a lambda function using the boto3 SDK in order to add autoscaling policies to a number of dynamoDB tables and indices, however it's consistently throwing this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>Relevant code here:</p>
  
  <pre><code>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)
          }
      }
    )
  </code></pre>
  
  <p>(resource_type is either 'table' or 'index'; capacity_type is either 'Read' or 'Write')</p>
  
  <p>A few solutions I've considered:</p>
  
  <ul>
  <li><p>fixing permissions - it was having some permissions issues before, I gave it AmazonDynamoDBFullAccess, which seems to have fixed all that. Also, presumably it would throw a different error if it didn't have access</p></li>
  <li><p>formatting of parameters - according to the API <a href="https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PutScalingPolicy.html" rel="nofollow noreferrer">here</a>, it all seems correct. I've tried variants like using the full ARN instead of table/tableName, using just tablename, etc.</p></li>
  <li><p>checking that tableName actually exists - it does, and I can add and remove scaling policies via the AWS console just fine</p></li>
  </ul>