Adding DynamoDB GlobalSecondaryIndex via CDK both requires AND disallows specify ReadCapacityUnits/WriteCapacityUnits

0

I'm trying to add a Global Secondary Index to an existing DynamoDB table that is defined thusly in the CDK:

const itemsTable = new Table(this, config.DYNAMODB_ID, {
            tableName: config.DYNAMODB_ID,
            partitionKey: { name: 'itemGuid', type: AttributeType.STRING },
            billingMode: BillingMode.PAY_PER_REQUEST,
            removalPolicy: RemovalPolicy.RETAIN,
            pointInTimeRecovery: true,
            deletionProtection: true,
        });

itemsTable.addGlobalSecondaryIndex({
            indexName: 'ItemsByType',
            partitionKey: { name: 'type', type: AttributeType.STRING },
            projectionType: ProjectionType.KEYS_ONLY,
        });

And I get an error as follows:

Resource handler returned message: "One or more parameter values were invalid: Both ReadCapacityUnits and WriteCapacityUnits must be specified for index: ItemsByType"

This despite the fact that the table is PAY_PER_REQUEST and according to the documentation I cannot specify these values, and if I do this:

assetTable.addGlobalSecondaryIndex({
            indexName: 'AssetsByType',
            partitionKey: { name: 'type', type: AttributeType.STRING },
            projectionType: ProjectionType.KEYS_ONLY,
            readCapacity: 5,
            writeCapacity: 5,
        });

I instead get this error:

Error: you cannot provision read and write capacity for a table with PAY_PER_REQUEST billing mode
  • For what it's worth, it seems like this error gets thrown immediately on trying to run the deploy:

    Error: you cannot provision read and write capacity for a table with PAY_PER_REQUEST billing mode
    

    and the other one, demanding "ReadCapacityUnits" and "WriteCapacityUnits", gets thrown after it starts the deploy and works its way through to the part where it would be adding the index.

Timothy
asked 8 months ago561 views
1 Answer
-1
Accepted Answer

Never mind - apparently the issue here was that exactly one of our lower environments was somehow set to Provisioned at some point and this isn't apparently changed by CDK deploys. Once I manually changed that, it worked.

Timothy
answered 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions