@gradientedge/cdk-utils 6.16.0 → 7.1.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.
@@ -1,12 +1,14 @@
1
1
  import * as cdk from 'aws-cdk-lib';
2
2
  import * as apig from 'aws-cdk-lib/aws-apigateway';
3
+ import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
3
4
  import * as iam from 'aws-cdk-lib/aws-iam';
4
5
  import * as lambda from 'aws-cdk-lib/aws-lambda';
5
6
  import * as logs from 'aws-cdk-lib/aws-logs';
7
+ import * as sqs from 'aws-cdk-lib/aws-sqs';
6
8
  import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
9
+ import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
7
10
  import * as common from '../../common';
8
11
  import * as types from '../../types';
9
- import { SfnStateMachineProps } from '../../types';
10
12
  /**
11
13
  * @stability stable
12
14
  * @category cdk-utils.step-functions-manager
@@ -70,6 +72,36 @@ export declare class SfnManager {
70
72
  * @param {types.SfnWaitProps} props
71
73
  */
72
74
  createWaitStep(id: string, scope: common.CommonConstruct, props: types.SfnWaitProps): cdk.aws_stepfunctions.Wait;
75
+ /**
76
+ * @summary Method to create a DynamoDB get item step
77
+ * @param {string} id scoped id of the resource
78
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
79
+ * @param {types.SfnDynamoGetItemProps} props
80
+ * @param {dynamodb.ITable} table The table to get the item from
81
+ * @param tableKey The table key for query/scan
82
+ */
83
+ createDynamoDbGetItemStep(id: string, scope: common.CommonConstruct, props: types.SfnDynamoGetItemProps, table: dynamodb.ITable, tableKey: {
84
+ [key: string]: tasks.DynamoAttributeValue;
85
+ }): cdk.aws_stepfunctions_tasks.DynamoGetItem;
86
+ /**
87
+ * @summary Method to create a DynamoDB put item step
88
+ * @param {string} id scoped id of the resource
89
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
90
+ * @param {types.SfnDynamoPutItemProps} props
91
+ * @param {dynamodb.ITable} table The table to put the item in
92
+ * @param tableItem The item to add to the table
93
+ */
94
+ createDynamoDbPutItemStep(id: string, scope: common.CommonConstruct, props: types.SfnDynamoPutItemProps, table: dynamodb.ITable, tableItem: {
95
+ [key: string]: tasks.DynamoAttributeValue;
96
+ }): cdk.aws_stepfunctions_tasks.DynamoPutItem;
97
+ /**
98
+ * @summary Method to send a message to SQS step
99
+ * @param {string} id scoped id of the resource
100
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
101
+ * @param {types.SfnSqsSendMessageProps} props
102
+ * @param {sqs.IQueue} queue The queue to send the message to
103
+ */
104
+ createSendSqsMessageStep(id: string, scope: common.CommonConstruct, props: types.SfnSqsSendMessageProps, queue: sqs.IQueue): cdk.aws_stepfunctions_tasks.SqsSendMessage;
73
105
  /**
74
106
  * @summary Method to create a lambda invoke step
75
107
  * @param {string} id scoped id of the resource
@@ -95,5 +127,5 @@ export declare class SfnManager {
95
127
  * @param {logs.ILogGroup} logGroup
96
128
  * @param {iam.IRole} role
97
129
  */
98
- createStateMachine(id: string, scope: common.CommonConstruct, props: SfnStateMachineProps, definition: sfn.IChainable, logGroup: logs.ILogGroup, role?: iam.IRole): cdk.aws_stepfunctions.StateMachine;
130
+ createStateMachine(id: string, scope: common.CommonConstruct, props: types.SfnStateMachineProps, definition: sfn.IChainable, logGroup: logs.ILogGroup, role?: iam.IRole): cdk.aws_stepfunctions.StateMachine;
99
131
  }
@@ -144,6 +144,101 @@ class SfnManager {
144
144
  },
145
145
  });
146
146
  }
147
+ /**
148
+ * @summary Method to create a DynamoDB get item step
149
+ * @param {string} id scoped id of the resource
150
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
151
+ * @param {types.SfnDynamoGetItemProps} props
152
+ * @param {dynamodb.ITable} table The table to get the item from
153
+ * @param tableKey The table key for query/scan
154
+ */
155
+ createDynamoDbGetItemStep(id, scope, props, table, tableKey) {
156
+ if (!props)
157
+ throw 'Step props undefined';
158
+ return new tasks.DynamoGetItem(scope, `${props.name}`, {
159
+ ...props,
160
+ ...{
161
+ table: table,
162
+ key: tableKey,
163
+ consistentRead: props.consistentRead,
164
+ inputPath: props.inputPath,
165
+ outputPath: props.outputPath,
166
+ resultPath: props.resultPath,
167
+ resultSelector: props.resultSelector,
168
+ timeout: props.timeout,
169
+ heartbeat: props.heartbeat,
170
+ integrationPattern: props.integrationPattern,
171
+ expressionAttributeNames: props.expressionAttributeNames,
172
+ projectionExpression: props.projectionExpression,
173
+ returnConsumedCapacity: props.returnConsumedCapacity,
174
+ comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
175
+ },
176
+ });
177
+ }
178
+ /**
179
+ * @summary Method to create a DynamoDB put item step
180
+ * @param {string} id scoped id of the resource
181
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
182
+ * @param {types.SfnDynamoPutItemProps} props
183
+ * @param {dynamodb.ITable} table The table to put the item in
184
+ * @param tableItem The item to add to the table
185
+ */
186
+ createDynamoDbPutItemStep(id, scope, props, table, tableItem) {
187
+ if (!props)
188
+ throw 'Step props undefined';
189
+ return new tasks.DynamoPutItem(scope, `${props.name}`, {
190
+ ...props,
191
+ ...{
192
+ table: table,
193
+ item: tableItem,
194
+ inputPath: props.inputPath,
195
+ outputPath: props.outputPath,
196
+ resultPath: props.resultPath,
197
+ resultSelector: props.resultSelector,
198
+ timeout: props.timeout,
199
+ heartbeat: props.heartbeat,
200
+ integrationPattern: props.integrationPattern,
201
+ conditionExpression: props.conditionExpression,
202
+ expressionAttributeNames: props.expressionAttributeNames,
203
+ expressionAttributeValues: props.expressionAttributeValues,
204
+ returnConsumedCapacity: props.returnConsumedCapacity,
205
+ returnItemCollectionMetrics: props.returnItemCollectionMetrics,
206
+ returnValues: props.returnValues,
207
+ comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
208
+ },
209
+ });
210
+ }
211
+ /**
212
+ * @summary Method to send a message to SQS step
213
+ * @param {string} id scoped id of the resource
214
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
215
+ * @param {types.SfnSqsSendMessageProps} props
216
+ * @param {sqs.IQueue} queue The queue to send the message to
217
+ */
218
+ createSendSqsMessageStep(id, scope, props, queue) {
219
+ if (!props)
220
+ throw 'Step props undefined';
221
+ if (!props.messageBody)
222
+ throw 'Message body undefined';
223
+ return new tasks.SqsSendMessage(scope, `${props.name}`, {
224
+ ...props,
225
+ ...{
226
+ queue: queue,
227
+ messageBody: props.messageBody,
228
+ messageGroupId: props.messageGroupId,
229
+ messageDeduplicationId: props.messageDeduplicationId,
230
+ delay: props.delay,
231
+ inputPath: props.inputPath,
232
+ outputPath: props.outputPath,
233
+ resultPath: props.resultPath,
234
+ resultSelector: props.resultSelector,
235
+ timeout: props.timeout,
236
+ heartbeat: props.heartbeat,
237
+ integrationPattern: props.integrationPattern,
238
+ comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
239
+ },
240
+ });
241
+ }
147
242
  /**
148
243
  * @summary Method to create a lambda invoke step
149
244
  * @param {string} id scoped id of the resource
@@ -64,7 +64,7 @@ class VpcManager {
64
64
  throw 'Vpc props undefined';
65
65
  const vpc = new ec2.Vpc(scope, `${id}`, {
66
66
  maxAzs: props.maxAzs,
67
- cidr: props.cidr,
67
+ ipAddresses: props.ipAddresses,
68
68
  });
69
69
  utils.createCfnOutput(`${id}Id`, scope, vpc.vpcId);
70
70
  utils.createCfnOutput(`${id}PublicSubnetIds`, scope, vpc.publicSubnets.map(subnet => subnet.subnetId).toString());
@@ -135,6 +135,27 @@ export interface SfnFailProps extends sfn.FailProps {
135
135
  export interface SfnPassProps extends sfn.PassProps {
136
136
  name: string;
137
137
  }
138
+ /**
139
+ * @category cdk-utils.step-functions-manager
140
+ * @subcategory Properties
141
+ */
142
+ export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
143
+ name: string;
144
+ }
145
+ /**
146
+ * @category cdk-utils.step-functions-manager
147
+ * @subcategory Properties
148
+ */
149
+ export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
150
+ name: string;
151
+ }
152
+ /**
153
+ * @category cdk-utils.step-functions-manager
154
+ * @subcategory Properties
155
+ */
156
+ export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
157
+ name: string;
158
+ }
138
159
  /**
139
160
  * @category cdk-utils.step-functions-manager
140
161
  * @subcategory Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "6.16.0",
3
+ "version": "7.1.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -45,12 +45,12 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@types/lodash": "^4.14.186",
49
- "@types/node": "^18.11.2",
48
+ "@types/lodash": "^4.14.188",
49
+ "@types/node": "^18.11.9",
50
50
  "app-root-path": "^3.1.0",
51
- "aws-cdk-lib": "^2.46.0",
52
- "aws-sdk": "^2.1235.0",
53
- "constructs": "^10.1.133",
51
+ "aws-cdk-lib": "^2.50.0",
52
+ "aws-sdk": "^2.1248.0",
53
+ "constructs": "^10.1.150",
54
54
  "lodash": "^4.17.21",
55
55
  "moment": "^2.29.4",
56
56
  "nconf": "^0.12.0",
@@ -59,23 +59,23 @@
59
59
  },
60
60
  "devDependencies": {
61
61
  "@babel/plugin-proposal-class-properties": "^7.18.6",
62
- "@types/jest": "^29.2.0",
63
- "@typescript-eslint/eslint-plugin": "^5.40.1",
64
- "@typescript-eslint/parser": "^5.40.1",
62
+ "@types/jest": "^29.2.2",
63
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
64
+ "@typescript-eslint/parser": "^5.42.0",
65
65
  "aws-cdk": "*",
66
66
  "babel-eslint": "^10.1.0",
67
67
  "better-docs": "^2.7.2",
68
68
  "codecov": "^3.8.3",
69
69
  "commitizen": "^4.2.5",
70
70
  "dotenv": "^16.0.3",
71
- "eslint": "^8.25.0",
71
+ "eslint": "^8.26.0",
72
72
  "eslint-config-prettier": "^8.5.0",
73
73
  "eslint-plugin-import": "^2.26.0",
74
74
  "husky": "^8.0.1",
75
- "jest": "^29.2.1",
75
+ "jest": "^29.2.2",
76
76
  "jest-extended": "^3.1.0",
77
77
  "jest-junit": "^14.0.1",
78
- "jsdoc": "^3.6.11",
78
+ "jsdoc": "^4.0.0",
79
79
  "jsdoc-babel": "^0.5.0",
80
80
  "jsdoc-mermaid": "^1.0.0",
81
81
  "lerna": "^5.6.2",
@@ -83,12 +83,13 @@
83
83
  "prettier-plugin-organize-imports": "^3.1.1",
84
84
  "rimraf": "^3.0.2",
85
85
  "semantic-release": "^19.0.5",
86
+ "taffydb": "^2.7.3",
86
87
  "ts-jest": "^29.0.3",
87
88
  "ts-node": "^10.9.1",
88
89
  "typescript": "4.8.4"
89
90
  },
90
91
  "optionalDependencies": {
91
- "@babel/core": "^7.19.3",
92
+ "@babel/core": "^7.20.2",
92
93
  "prop-types": "^15.8.1",
93
94
  "react": "^18.2.0",
94
95
  "react-dom": "^18.2.0"
@@ -1,13 +1,14 @@
1
1
  import * as cdk from 'aws-cdk-lib'
2
2
  import * as apig from 'aws-cdk-lib/aws-apigateway'
3
+ import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'
3
4
  import * as iam from 'aws-cdk-lib/aws-iam'
4
5
  import * as lambda from 'aws-cdk-lib/aws-lambda'
5
6
  import * as logs from 'aws-cdk-lib/aws-logs'
7
+ import * as sqs from 'aws-cdk-lib/aws-sqs'
6
8
  import * as sfn from 'aws-cdk-lib/aws-stepfunctions'
7
9
  import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'
8
10
  import * as common from '../../common'
9
11
  import * as types from '../../types'
10
- import { SfnStateMachineProps } from '../../types'
11
12
  import * as utils from '../../utils'
12
13
 
13
14
  /**
@@ -127,6 +128,117 @@ export class SfnManager {
127
128
  })
128
129
  }
129
130
 
131
+ /**
132
+ * @summary Method to create a DynamoDB get item step
133
+ * @param {string} id scoped id of the resource
134
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
135
+ * @param {types.SfnDynamoGetItemProps} props
136
+ * @param {dynamodb.ITable} table The table to get the item from
137
+ * @param tableKey The table key for query/scan
138
+ */
139
+ public createDynamoDbGetItemStep(
140
+ id: string,
141
+ scope: common.CommonConstruct,
142
+ props: types.SfnDynamoGetItemProps,
143
+ table: dynamodb.ITable,
144
+ tableKey: { [key: string]: tasks.DynamoAttributeValue }
145
+ ) {
146
+ if (!props) throw 'Step props undefined'
147
+ return new tasks.DynamoGetItem(scope, `${props.name}`, {
148
+ ...props,
149
+ ...{
150
+ table: table,
151
+ key: tableKey,
152
+ consistentRead: props.consistentRead,
153
+ inputPath: props.inputPath,
154
+ outputPath: props.outputPath,
155
+ resultPath: props.resultPath,
156
+ resultSelector: props.resultSelector,
157
+ timeout: props.timeout,
158
+ heartbeat: props.heartbeat,
159
+ integrationPattern: props.integrationPattern,
160
+ expressionAttributeNames: props.expressionAttributeNames,
161
+ projectionExpression: props.projectionExpression,
162
+ returnConsumedCapacity: props.returnConsumedCapacity,
163
+ comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
164
+ },
165
+ })
166
+ }
167
+
168
+ /**
169
+ * @summary Method to create a DynamoDB put item step
170
+ * @param {string} id scoped id of the resource
171
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
172
+ * @param {types.SfnDynamoPutItemProps} props
173
+ * @param {dynamodb.ITable} table The table to put the item in
174
+ * @param tableItem The item to add to the table
175
+ */
176
+ public createDynamoDbPutItemStep(
177
+ id: string,
178
+ scope: common.CommonConstruct,
179
+ props: types.SfnDynamoPutItemProps,
180
+ table: dynamodb.ITable,
181
+ tableItem: { [key: string]: tasks.DynamoAttributeValue }
182
+ ) {
183
+ if (!props) throw 'Step props undefined'
184
+ return new tasks.DynamoPutItem(scope, `${props.name}`, {
185
+ ...props,
186
+ ...{
187
+ table: table,
188
+ item: tableItem,
189
+ inputPath: props.inputPath,
190
+ outputPath: props.outputPath,
191
+ resultPath: props.resultPath,
192
+ resultSelector: props.resultSelector,
193
+ timeout: props.timeout,
194
+ heartbeat: props.heartbeat,
195
+ integrationPattern: props.integrationPattern,
196
+ conditionExpression: props.conditionExpression,
197
+ expressionAttributeNames: props.expressionAttributeNames,
198
+ expressionAttributeValues: props.expressionAttributeValues,
199
+ returnConsumedCapacity: props.returnConsumedCapacity,
200
+ returnItemCollectionMetrics: props.returnItemCollectionMetrics,
201
+ returnValues: props.returnValues,
202
+ comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
203
+ },
204
+ })
205
+ }
206
+
207
+ /**
208
+ * @summary Method to send a message to SQS step
209
+ * @param {string} id scoped id of the resource
210
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
211
+ * @param {types.SfnSqsSendMessageProps} props
212
+ * @param {sqs.IQueue} queue The queue to send the message to
213
+ */
214
+ public createSendSqsMessageStep(
215
+ id: string,
216
+ scope: common.CommonConstruct,
217
+ props: types.SfnSqsSendMessageProps,
218
+ queue: sqs.IQueue
219
+ ) {
220
+ if (!props) throw 'Step props undefined'
221
+ if (!props.messageBody) throw 'Message body undefined'
222
+ return new tasks.SqsSendMessage(scope, `${props.name}`, {
223
+ ...props,
224
+ ...{
225
+ queue: queue,
226
+ messageBody: props.messageBody,
227
+ messageGroupId: props.messageGroupId,
228
+ messageDeduplicationId: props.messageDeduplicationId,
229
+ delay: props.delay,
230
+ inputPath: props.inputPath,
231
+ outputPath: props.outputPath,
232
+ resultPath: props.resultPath,
233
+ resultSelector: props.resultSelector,
234
+ timeout: props.timeout,
235
+ heartbeat: props.heartbeat,
236
+ integrationPattern: props.integrationPattern,
237
+ comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
238
+ },
239
+ })
240
+ }
241
+
130
242
  /**
131
243
  * @summary Method to create a lambda invoke step
132
244
  * @param {string} id scoped id of the resource
@@ -186,7 +298,7 @@ export class SfnManager {
186
298
  public createStateMachine(
187
299
  id: string,
188
300
  scope: common.CommonConstruct,
189
- props: SfnStateMachineProps,
301
+ props: types.SfnStateMachineProps,
190
302
  definition: sfn.IChainable,
191
303
  logGroup: logs.ILogGroup,
192
304
  role?: iam.IRole
@@ -40,7 +40,7 @@ export class VpcManager {
40
40
  if (!props) throw 'Vpc props undefined'
41
41
  const vpc = new ec2.Vpc(scope, `${id}`, {
42
42
  maxAzs: props.maxAzs,
43
- cidr: props.cidr,
43
+ ipAddresses: props.ipAddresses,
44
44
  })
45
45
 
46
46
  utils.createCfnOutput(`${id}Id`, scope, vpc.vpcId)
@@ -144,6 +144,30 @@ export interface SfnPassProps extends sfn.PassProps {
144
144
  name: string
145
145
  }
146
146
 
147
+ /**
148
+ * @category cdk-utils.step-functions-manager
149
+ * @subcategory Properties
150
+ */
151
+ export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
152
+ name: string
153
+ }
154
+
155
+ /**
156
+ * @category cdk-utils.step-functions-manager
157
+ * @subcategory Properties
158
+ */
159
+ export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
160
+ name: string
161
+ }
162
+
163
+ /**
164
+ * @category cdk-utils.step-functions-manager
165
+ * @subcategory Properties
166
+ */
167
+ export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
168
+ name: string
169
+ }
170
+
147
171
  /**
148
172
  * @category cdk-utils.step-functions-manager
149
173
  * @subcategory Properties