I am setting up the creation of AWS resources in the AWS Cloud Formation template. I set up my dynamoDb table resource such that with every new stack, it creates a unique instance of the DynamoDb Table, and it's not a fixed name.
I used the following code in the cloud formation template:
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
I am trying to set up an application auto-scaling target for this dynamo DB resource with this code. But i am not sure how to point it to the table created above.
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
At deployment, the auto-scaling resource is getting created before dynamo DB and thus cloud formation deployment is failing.
Please help.