amazon-dynamodbamazon-dynamodb-index

dynamodb GSI index is emtpy


I have a dynamodb table with pk = userID (String) sk = ServiceID (String), also i have a gsi ClusterID-createdAt-index where pk is ClusterID (String) and the sort key is createdAt (Number)

{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "ClusterID",
                "AttributeType": "S"
            },
            {
                "AttributeName": "ServiceID",
                "AttributeType": "S"
            },
            {
                "AttributeName": "createdAt",
                "AttributeType": "N"
            },
            {
                "AttributeName": "userID",
                "AttributeType": "S"
            }
        ],
        "TableName": "OndemandPreviewEnvironments",
        "KeySchema": [
            {
                "AttributeName": "userID",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "ServiceID",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": "****",
        "ProvisionedThroughput": {
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 0,
            "WriteCapacityUnits": 0
        },
        "TableSizeBytes": 146,
        "ItemCount": 2,
        "TableArn": "****",
        "TableId": "48165285-c1bf-4876-aa9c-80d20f3b24e6",
        "BillingModeSummary": {
            "BillingMode": "PAY_PER_REQUEST",
            "LastUpdateToPayPerRequestDateTime": "****"
        },
        "GlobalSecondaryIndexes": [
            {
                "IndexName": "ClusterID-createdAt-index",
                "KeySchema": [
                    {
                        "AttributeName": "ClusterID",
                        "KeyType": "HASH"
                    },
                    {
                        "AttributeName": "createdAt",
                        "KeyType": "RANGE"
                    }
                ],
                "Projection": {
                    "ProjectionType": "ALL"
                },
                "IndexStatus": "ACTIVE",
                "ProvisionedThroughput": {
                    "NumberOfDecreasesToday": 0,
                    "ReadCapacityUnits": 0,
                    "WriteCapacityUnits": 0
                },
                "IndexSizeBytes": 0,
                "ItemCount": 0,
                "IndexArn": "****"
            }
        ]
    }
}

now when I put an item to the table:

    item = {
        "userID": {
            "S": user_id
        },
        "ServiceID": {
            "S": app
        },
        "ClusterID": {
            "S": cluster_name
        },
            "CreatedAt": {
            "N": str(current_time)
            },
            "Namespace": {
            "S": "namespace"
        },
            "Ingress": {
            "S": "ingress"
        },
        }

I expect to be able to execute a query on the index where ClusterID="foo" and createdAt greater than X. But the issue is that my index always has 0 items (Items returned (0)). even after a few days.

Does anybody know what am I missing?


Solution

  • Your GSI defined createdAt but your item has CreatedAt. The casing does not match.