DynamoDB 自动扩展、应用程序自动扩展

DynamoDB 自动扩展、应用程序自动扩展

我正在尝试设置一组可以创建新用户和 dynamoDB 表的 boto3 python AWS 脚本,以便我正在开发的 Web 应用程序可以添加具有适当范围的权限的新用户。

我无法获取脚本来将自动扩展添加到 dynamodb 表。我创建了一个 IAM 策略,我认为它过于宽泛 - 添加了大多数自动扩展和应用程序自动扩展选项,试图找出我需要什么,但我似乎仍然没有权限将自动扩展添加到我的 dynamodb 表。希望有人能发现我遗漏了什么。

下面我将展示 IAM 策略和尝试添加自动扩展的 Python 代码片段。

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "application-autoscaling:RegisterScalableTarget",
                "application-autoscaling:PutScalingPolicy",
                "application-autoscaling:ListTagsForResource",
                "application-autoscaling:TagResource",
                "application-autoscaling:PutScheduledAction"
            ],
            "Resource": "arn:aws:application-autoscaling:*:221969118281:scalable-target/*"
        },
        {
            "Sid": "VisualEditor1",
            "Effect": "Allow",
            "Action": [
                "application-autoscaling:DescribeScalableTargets",
                "autoscaling-plans:DescribeScalingPlans",
                "autoscaling-plans:UpdateScalingPlan",
                "application-autoscaling:DescribeScalingActivities",
                "application-autoscaling:DescribeScalingPolicies",
                "application-autoscaling:DescribeScheduledActions",
                "autoscaling-plans:GetScalingPlanResourceForecastData",
                "autoscaling-plans:DescribeScalingPlanResources",
                "autoscaling-plans:CreateScalingPlan"
            ],
            "Resource": "*"
        }
    ]
}


  response = client.put_scaling_policy(
      PolicyName= prefix + '_' + table + "_read_scaling",
      ServiceNamespace='dynamodb',
      ResourceId='table/' + prefix + '_' + table,
      ScalableDimension='dynamodb:table:ReadCapacityUnits',
      PolicyType='StepScaling',
      StepScalingPolicyConfiguration={
          'AdjustmentType': 'ChangeInCapacity',
          'StepAdjustments': [
              {
                  'MetricIntervalLowerBound': 1,
                  'MetricIntervalUpperBound': 20,
                  'ScalingAdjustment': 2
              },
          ],
          'MinAdjustmentMagnitude': 2,
          'Cooldown': 120,
          'MetricAggregationType': 'Average'
      }
  )

  response = client.put_scaling_policy(
      PolicyName= prefix + '_' + table + "_write_scaling",
      ServiceNamespace='dynamodb',
      ResourceId='table/' + prefix + '_' + table,
      ScalableDimension='dynamodb:table:WriteCapacityUnits',
      PolicyType='StepScaling',
      StepScalingPolicyConfiguration={
          'AdjustmentType': 'ChangeInCapacity',
          'StepAdjustments': [
              {
                  'MetricIntervalLowerBound': 1,
                  'MetricIntervalUpperBound': 20,
                  'ScalingAdjustment': 2
              },
          ],
          'MinAdjustmentMagnitude': 2,
          'Cooldown': 120,
          'MetricAggregationType': 'Average'
      }
  )

相关内容