I'm trying to setup a set of boto3 python AWS scripts which can create new users and dynamoDB tables, so that the web app I'm working on can add new users with properly scoped permissions.
I'm having trouble getting the scripts to add auto-scaling to the dynamodb tables. I've created an IAM policy which I think is over-broad - adding most of the auto-scaling and application auto-scaling options, in trying to find out what I need, but I still don't seem to have permission to add the auto-scaling to my dynamodb tables. Hoping someone can spot what I'm missing.
Below I'll show the IAM policy and the python snippet which attempts to add the auto-scaling.
{
"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'
}
)