@gradientedge/cdk-utils 8.131.0 → 8.132.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/lib/aws/services/dynamodb/main.d.ts +9 -2
- package/dist/src/lib/aws/services/dynamodb/main.js +17 -0
- package/dist/src/lib/aws/services/dynamodb/types.d.ts +2 -0
- package/package.json +1 -1
- package/src/lib/aws/services/dynamodb/main.ts +22 -2
- package/src/lib/aws/services/dynamodb/types.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Table } from 'aws-cdk-lib/aws-dynamodb';
|
|
1
|
+
import { Table, TableV2 } from 'aws-cdk-lib/aws-dynamodb';
|
|
2
2
|
import { CommonConstruct } from '../../common';
|
|
3
|
-
import { TableProps } from './types';
|
|
3
|
+
import { TableProps, TablePropsV2 } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc Provides operations on AWS DynamoDB
|
|
6
6
|
* - A new instance of this class is injected into {@link CommonConstruct} constructor.
|
|
@@ -25,4 +25,11 @@ export declare class DynamodbManager {
|
|
|
25
25
|
* @param props table props
|
|
26
26
|
*/
|
|
27
27
|
createTable(id: string, scope: CommonConstruct, props: TableProps): Table;
|
|
28
|
+
/**
|
|
29
|
+
* @summary Method to create a table
|
|
30
|
+
* @param id scoped id of the resource
|
|
31
|
+
* @param scope scope in which this resource is defined
|
|
32
|
+
* @param props table props
|
|
33
|
+
*/
|
|
34
|
+
createTableV2(id: string, scope: CommonConstruct, props: TablePropsV2): TableV2;
|
|
28
35
|
}
|
|
@@ -47,5 +47,22 @@ class DynamodbManager {
|
|
|
47
47
|
(0, utils_1.createCfnOutput)(`${id}-tableArn`, scope, table.tableArn);
|
|
48
48
|
return table;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* @summary Method to create a table
|
|
52
|
+
* @param id scoped id of the resource
|
|
53
|
+
* @param scope scope in which this resource is defined
|
|
54
|
+
* @param props table props
|
|
55
|
+
*/
|
|
56
|
+
createTableV2(id, scope, props) {
|
|
57
|
+
if (!props)
|
|
58
|
+
throw `Table props undefined for ${id}`;
|
|
59
|
+
const table = new aws_dynamodb_1.TableV2(scope, `${id}`, {
|
|
60
|
+
...props,
|
|
61
|
+
tableName: `${props.tableName}-${scope.props.stage}`,
|
|
62
|
+
});
|
|
63
|
+
(0, utils_1.createCfnOutput)(`${id}-tableName`, scope, table.tableName);
|
|
64
|
+
(0, utils_1.createCfnOutput)(`${id}-tableArn`, scope, table.tableArn);
|
|
65
|
+
return table;
|
|
66
|
+
}
|
|
50
67
|
}
|
|
51
68
|
exports.DynamodbManager = DynamodbManager;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Tags } from 'aws-cdk-lib'
|
|
2
|
-
import { Table } from 'aws-cdk-lib/aws-dynamodb'
|
|
2
|
+
import { Table, TableV2 } from 'aws-cdk-lib/aws-dynamodb'
|
|
3
3
|
import _ from 'lodash'
|
|
4
4
|
import { CommonConstruct } from '../../common'
|
|
5
5
|
import { createCfnOutput } from '../../utils'
|
|
6
|
-
import { TableProps } from './types'
|
|
6
|
+
import { TableProps, TablePropsV2 } from './types'
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @classdesc Provides operations on AWS DynamoDB
|
|
@@ -47,4 +47,24 @@ export class DynamodbManager {
|
|
|
47
47
|
|
|
48
48
|
return table
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @summary Method to create a table
|
|
53
|
+
* @param id scoped id of the resource
|
|
54
|
+
* @param scope scope in which this resource is defined
|
|
55
|
+
* @param props table props
|
|
56
|
+
*/
|
|
57
|
+
public createTableV2(id: string, scope: CommonConstruct, props: TablePropsV2) {
|
|
58
|
+
if (!props) throw `Table props undefined for ${id}`
|
|
59
|
+
|
|
60
|
+
const table = new TableV2(scope, `${id}`, {
|
|
61
|
+
...props,
|
|
62
|
+
tableName: `${props.tableName}-${scope.props.stage}`,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
createCfnOutput(`${id}-tableName`, scope, table.tableName)
|
|
66
|
+
createCfnOutput(`${id}-tableArn`, scope, table.tableArn)
|
|
67
|
+
|
|
68
|
+
return table
|
|
69
|
+
}
|
|
50
70
|
}
|