I want to create a table of dynamicb hash+renge attributes in cloudformation, but I get an error.

Asked 2 years ago, Updated 2 years ago, 103 views

If I want the key schema to hash+renge, how do I write it correctly?

Error Occurred

1 validation error detected: Value 'RENGE' at'keySchema.
2.member.keyType'failed to satify constraint: Member must satify enum value set: [HASH,RANGE] (Service: AmazonDynamoDBv2;
Status Code: 400; Error Code: ValidationException; Request ID: L6GDTPVEFBAVKUOA4DR2LM9SHBV4KQNSO5AEMVJF66Q9ASUAAJG)

Here's an excerpt of the dynamicb resource creation code only

"DynamoDBTable": {
    "Type": "AWS::DynamoDB::Table",
    "Properties": {
        "TableName": {"Ref": "DynamoDBTableName",
        "BillingMode": "PAY_PER_REQUEST",
        AttributeDefinitions: [
            {
                "AttributeName": "Id",
                "AttributeType": "S"
            },
            {
                "AttributeName": "Time",
                "AttributeType": "N"
            }
        ],
        "KeySchema": [
            {
                "AttributeName": "Id",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "Time",
                "KeyType": "RENGE"
            }
        ],
        "Tags": [
            {
                "Key": "Name",
                "Value": {"Ref": "DynamoDBTableName"}
            }
        ]
    }
},

aws aws-lambda aws-cloudformation

2022-09-30 15:44

1 Answers

It was RANGE, not RENGE, because of a spelling error.

"DynamoDBTable": {
    "Type": "AWS::DynamoDB::Table",
    "Properties": {
        "TableName": {"Ref": "DynamoDBTableName",
        "BillingMode": "PAY_PER_REQUEST",
        AttributeDefinitions: [
            {
                "AttributeName": "Id",
                "AttributeType": "S"
            },
            {
                "AttributeName": "Time",
                "AttributeType": "N"
            }
        ],
        "KeySchema": [
            {
                "AttributeName": "Id",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "Time",
                "KeyType": "Range"
            }
        ],
        "Tags": [
            {
                "Key": "Name",
                "Value": {"Ref": "DynamoDBTableName"}
            }
        ]
    }
},


2022-09-30 15:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.