gpt4 book ai didi

amazon-web-services - 通过 CloudFormation 为现有表添加自动缩放功能到 AWS DynamoDB

转载 作者:行者123 更新时间:2023-12-01 22:15:52 27 4
gpt4 key购买 nike

我们的团队非常高兴看到 AWS DynamoDB 宣布推出自动扩展功能,并且在通过在 Web 界面中添加配置来尝试该功能时,我们发现这非常适合我们应用程序的四种需求。

然而,事实证明,尝试通过 CF 添加相同的配置要复杂一些。本文提供以下示例 - http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html#cfn-dynamodb-table-examples-application-autoscaling - 下面是结果,但不起作用。堆栈详细信息:


17:02:25 UTC+0300 UPDATE_ROLLBACK_IN_PROGRESS AWS::CloudFormation::Stack my-stack The following resource(s) failed to create: [WriteCapacityScalableTarget].
17:02:24 UTC+0300 CREATE_FAILED AWS::ApplicationAutoScaling::ScalableTarget WriteCapacityScalableTarget table/TableName|dynamodb:table:WriteCapacityUnits|dynamodb already exists
17:02:18 UTC+0300 CREATE_IN_PROGRESS AWS::ApplicationAutoScaling::ScalableTarget WriteCapacityScalableTarget<br/>
17:02:15 UTC+0300 CREATE_COMPLETE AWS::IAM::Role ScalingRole<br/>
17:01:42 UTC+0300 CREATE_IN_PROGRESS AWS::IAM::Role ScalingRole Resource creation Initiated
17:01:42 UTC+0300 CREATE_IN_PROGRESS AWS::IAM::Role ScalingRole<br/>
17:01:37 UTC+0300 UPDATE_IN_PROGRESS AWS::CloudFormation::Stack my-stack User Initiated

我的CF脚本如下:

{
"Resources": {
"MyCustomTableName": {
"Type": "AWS::DynamoDB::Table",
"Properties": {
"TableName": "TableName",
"AttributeDefinitions": [
{
"AttributeName": "someAttribute1:someAttribute2",
"AttributeType": "S"
}
],
"KeySchema": [
{
"AttributeName": "someAttribute1:someAttribute2",
"KeyType": "HASH"
}
],
"ProvisionedThroughput": {
"ReadCapacityUnits": 1,
"WriteCapacityUnits": 1
},
"StreamSpecification": {
"StreamViewType": "NEW_AND_OLD_IMAGES"
}
}
},
"WriteCapacityScalableTarget": {
"Type": "AWS::ApplicationAutoScaling::ScalableTarget",
"Properties": {
"MaxCapacity": 30,
"MinCapacity": 1,
"ResourceId": {
"Fn::Join": [
"/",
[
"table",
{
"Ref": "MyCustomTableName"
}
]
]
},
"RoleARN": {
"Fn::GetAtt": [
"ScalingRole",
"Arn"
]
},
"ScalableDimension": "dynamodb:table:WriteCapacityUnits",
"ServiceNamespace": "dynamodb"
}
},
"ScalingRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"application-autoscaling.amazonaws.com"
]
},
"Action": [
"sts:AssumeRole"
]
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "root",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:DescribeTable",
"dynamodb:UpdateTable",
"cloudwatch:PutMetricAlarm",
"cloudwatch:DescribeAlarms",
"cloudwatch:GetMetricStatistics",
"cloudwatch:SetAlarmState",
"cloudwatch:DeleteAlarms"
],
"Resource": "*"
}
]
}
}
]
}
},
"WriteScalingPolicy": {
"Type": "AWS::ApplicationAutoScaling::ScalingPolicy",
"Properties": {
"PolicyName": "WriteAutoScalingPolicy",
"PolicyType": "TargetTrackingScaling",
"ScalingTargetId": {
"Ref": "WriteCapacityScalableTarget"
},
"TargetTrackingScalingPolicyConfiguration": {
"TargetValue": 70.0,
"ScaleInCooldown": 60,
"ScaleOutCooldown": 60,
"PredefinedMetricSpecification": {
"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"
}
}
}
}
}
}

如果有人能解释为什么会发生这种情况,我将非常感激:)

最佳答案

根据错误消息进行操作

CREATE_FAILED AWS::ApplicationAutoScaling::ScalableTarget WriteCapacityScalableTarget 表/TableName|dynamodb:table:WriteCapacityUnits|dynamodb 已存在

您正在创建名为 "TableName": "TableName" 的 DynamoDB 资源。一个区域内不能有两个同名的 dynamoDB 表。

转到 DynamoDB 控制台并检查是否有此类表并将其删除。发布该模板应该可以正常工作。

选项 2:如果您想继续使用现有表,则可以从 CF 模板中删除 AWS::DynamoDB::Table 资源。

关于amazon-web-services - 通过 CloudFormation 为现有表添加自动缩放功能到 AWS DynamoDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46006886/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com