@gradientedge/cdk-utils 7.0.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.
@@ -4,6 +4,7 @@ import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
4
4
  import * as iam from 'aws-cdk-lib/aws-iam';
5
5
  import * as lambda from 'aws-cdk-lib/aws-lambda';
6
6
  import * as logs from 'aws-cdk-lib/aws-logs';
7
+ import * as sqs from 'aws-cdk-lib/aws-sqs';
7
8
  import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
8
9
  import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
9
10
  import * as common from '../../common';
@@ -75,13 +76,32 @@ export declare class SfnManager {
75
76
  * @summary Method to create a DynamoDB get item step
76
77
  * @param {string} id scoped id of the resource
77
78
  * @param {common.CommonConstruct} scope scope in which this resource is defined
78
- * @param {types.SfnPassProps} props
79
- * @param {dynamodb.ITable} table
80
- * @param tableKey
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
81
82
  */
82
83
  createDynamoDbGetItemStep(id: string, scope: common.CommonConstruct, props: types.SfnDynamoGetItemProps, table: dynamodb.ITable, tableKey: {
83
84
  [key: string]: tasks.DynamoAttributeValue;
84
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;
85
105
  /**
86
106
  * @summary Method to create a lambda invoke step
87
107
  * @param {string} id scoped id of the resource
@@ -148,9 +148,9 @@ class SfnManager {
148
148
  * @summary Method to create a DynamoDB get item step
149
149
  * @param {string} id scoped id of the resource
150
150
  * @param {common.CommonConstruct} scope scope in which this resource is defined
151
- * @param {types.SfnPassProps} props
152
- * @param {dynamodb.ITable} table
153
- * @param tableKey
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
154
  */
155
155
  createDynamoDbGetItemStep(id, scope, props, table, tableKey) {
156
156
  if (!props)
@@ -161,11 +161,84 @@ class SfnManager {
161
161
  table: table,
162
162
  key: tableKey,
163
163
  consistentRead: props.consistentRead,
164
+ inputPath: props.inputPath,
165
+ outputPath: props.outputPath,
164
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,
165
174
  comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
166
175
  },
167
176
  });
168
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
+ }
169
242
  /**
170
243
  * @summary Method to create a lambda invoke step
171
244
  * @param {string} id scoped id of the resource
@@ -142,6 +142,20 @@ export interface SfnPassProps extends sfn.PassProps {
142
142
  export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
143
143
  name: string;
144
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
+ }
145
159
  /**
146
160
  * @category cdk-utils.step-functions-manager
147
161
  * @subcategory Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "7.0.0",
3
+ "version": "7.1.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -4,6 +4,7 @@ import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'
4
4
  import * as iam from 'aws-cdk-lib/aws-iam'
5
5
  import * as lambda from 'aws-cdk-lib/aws-lambda'
6
6
  import * as logs from 'aws-cdk-lib/aws-logs'
7
+ import * as sqs from 'aws-cdk-lib/aws-sqs'
7
8
  import * as sfn from 'aws-cdk-lib/aws-stepfunctions'
8
9
  import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'
9
10
  import * as common from '../../common'
@@ -131,9 +132,9 @@ export class SfnManager {
131
132
  * @summary Method to create a DynamoDB get item step
132
133
  * @param {string} id scoped id of the resource
133
134
  * @param {common.CommonConstruct} scope scope in which this resource is defined
134
- * @param {types.SfnPassProps} props
135
- * @param {dynamodb.ITable} table
136
- * @param tableKey
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
137
138
  */
138
139
  public createDynamoDbGetItemStep(
139
140
  id: string,
@@ -149,12 +150,95 @@ export class SfnManager {
149
150
  table: table,
150
151
  key: tableKey,
151
152
  consistentRead: props.consistentRead,
153
+ inputPath: props.inputPath,
154
+ outputPath: props.outputPath,
152
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,
153
163
  comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
154
164
  },
155
165
  })
156
166
  }
157
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
+
158
242
  /**
159
243
  * @summary Method to create a lambda invoke step
160
244
  * @param {string} id scoped id of the resource
@@ -152,6 +152,22 @@ export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
152
152
  name: string
153
153
  }
154
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
+
155
171
  /**
156
172
  * @category cdk-utils.step-functions-manager
157
173
  * @subcategory Properties