Skip to content

Commit

Permalink
feat(cdk): timeToLiveAttribute for dynamo tables
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Mar 5, 2024
1 parent a942925 commit b343307
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/cdk/src/methods/dynamo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface AddTableOptions {
producers?: IGrantable[];
scope: DotStack;
sortKey?: Attribute;
timeToLiveAttribute?: string;
}

interface AddGlobalIndexOptions {
Expand All @@ -47,7 +48,14 @@ export const tableExists = ({ scope, tableName }: TableExistsOptions) => {
};

export const addTable = (options: AddTableOptions) => {
const { consumers = [], partitionKey, producers = [], scope, sortKey } = options;
const {
consumers = [],
partitionKey,
producers = [],
scope,
sortKey,
timeToLiveAttribute
} = options;
const name = options.name.replace(/-table$/, '');
const prefix = options.prefix ? `${scope.appName}-` : '';
const tableName = `${scope.envPrefix}${prefix}${name}`;
Expand All @@ -61,7 +69,8 @@ export const addTable = (options: AddTableOptions) => {
pointInTimeRecovery: scope.env === 'prod',
removalPolicy: RemovalPolicy.DESTROY,
sortKey,
tableName
tableName,
timeToLiveAttribute
});

scope.overrideId(table, tableId);
Expand Down

0 comments on commit b343307

Please sign in to comment.