我正在 AWS Cloud Formation 模板中设置 AWS 资源的创建。我设置了我的 dynamoDb 表资源,这样对于每个新堆栈,它都会创建 DynamoDb 表的唯一实例,并且它不是固定名称。
我在云形成模板中使用了以下代码:
DynamoDBTable:
Type: AWS::DynamoDB::Table
# Retain the table when deleting from CF Stack!
DeletionPolicy: Retain
Properties:
#TableName: !Sub "abc-${ClientVar}-DB-${EnvVar}"
#TableName: !Ref DbTableName
TableName: TrackOreDB # This is just for the autoscaling group. I need to find a way to validate it in the autoscaling resource by making the name generic for multiple stacks.
AttributeDefinitions:
- AttributeName: Product_ID
AttributeType: S
KeySchema:
- AttributeName: Product_ID
KeyType: HASH
我正在尝试使用此代码为此发电机数据库资源设置应用程序自动缩放目标。但我不确定如何将其指向上面创建的表格。
UserTableWriteCapacityScalableTarget:
Type: AWS::ApplicationAutoScaling::ScalableTarget
Properties:
MaxCapacity: 100
MinCapacity: 5
ResourceId: !Sub table/'abc-%s-DB-%s' % (client, env)
RoleARN: !Sub arn:aws:iam::${AWS::AccountId}:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable
ScalableDimension: dynamodb:table:WriteCapacityUnits
ServiceNamespace: dynamodb
在部署时,自动缩放资源在 dynamo DB 之前创建,因此云形成部署失败。
请帮忙。