Skip to main content

AwsDynamoDBServiceModule

AwsDynamoDBServiceModule creates one DynamoDB table with its key schema, secondary indexes, streams, billing mode, TTL, point-in-time recovery and deletion protection; a server is granted access to it through AwsServerModule.

@cost

With billingMode PAY_PER_REQUEST, DynamoDB bills each read and write (about $0.125 per million reads and $0.625 per million writes in us-east-1), so an idle table costs only its storage. With PROVISIONED, it bills the capacity reserved every hour, used or not. Storage is about $0.25 per GB-month, point-in-time recovery adds about $0.20 per GB-month, and a stream is free to write.

@downtime

None for a change made in place: the table keeps serving while a new global secondary index fills. A replacement deletes the table and creates an empty one.

@example

TypeScript

import { type Region, stub } from '@quadnix/octo';
import { AwsDynamoDBServiceModule } from '@quadnix/octo-aws-cdk/modules/service/aws-dynamodb-service';

octo.loadModule(AwsDynamoDBServiceModule, 'my-table-module', {
AttributeDefinitions: [{ AttributeName: 'AccountId', AttributeType: 'S' }],
billingMode: { settings: {}, type: 'PAY_PER_REQUEST' },
KeySchema: [{ AttributeName: 'AccountId', KeyType: 'HASH' }],
region: stub<Region>('${{my-region-module.model.region}}'),
TableName: 'my-table',
});
@group

Modules/Service/AwsDynamoDBService

@limit

One global secondary index is added per run, and an existing one never changes: remove it in one run and add its successor in the next. AWS allows 20 global and 5 local secondary indexes on a table.

@limit

An item holds at most 400 KB. Neither a join nor a query across tables exists: an app that needs them wants a relational database, which this module is not.

@limit

DeletionProtectionEnabled changes in a run that changes nothing else about the table.

@limit

The table class is STANDARD; STANDARD_INFREQUENT_ACCESS cannot be set.

@losesData

Deleting the module, or a change that replaces the table, deletes every item, which octo cannot put back. With DeletionProtectionEnabled, AWS refuses the deletion until protection is turned off in a run of its own. With PointInTimeRecoveryEnabled, AWS keeps a backup of a deleted table for 35 days.

@replaces

Changing TableName, KeySchema, LocalSecondaryIndexes or region replaces the table, because DynamoDB fixes them when the table is created. Every other input changes it in place.

@see

Hierarchy

Index

Constructors

constructor

  • Parameters

    • moduleId: string

      The ID this module is loaded under.

    Returns AwsDynamoDBServiceModule

Properties

readonlyinheritedmoduleId

moduleId: string

The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.

staticreadonlyinheritedMODULE_PACKAGE

MODULE_PACKAGE: string

The package the module is registered under, set by Module.

staticreadonlyinheritedMODULE_SCHEMA

MODULE_SCHEMA: any

The schema of the module's inputs, set by Module.

Methods

onInit

  • Creates the DynamoDB table service, and anchors its table name for other modules to find.


    Parameters

    Returns Promise<AwsDynamoDBService>

inheritedregisterHooks

  • registerHooks(): { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
  • To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.

    @see

    Techniques for Hooks.


    Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }

    • optionalpostCommitHooks?: PostHookSignature[]
    • optionalpostModelActionHooks?: PostHookSignature[]
    • optionalpostResourceActionHooks?: PostHookSignature[]
    • optionalpreCommitHooks?: PreHookSignature[]
    • optionalpreModelActionHooks?: PreHookSignature[]
    • optionalpreResourceActionHooks?: PreHookSignature[]

registerMetadata

  • Resolves the account and region this table is created in. The region may be networked or serverless; the table only needs its AWS region ID.


    Parameters

    Returns Promise<{ awsAccountId: string; awsRegionId: string }>