@gradientedge/cdk-utils 8.1.0 → 8.3.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.
@@ -212,7 +212,7 @@ class LambdaManager {
212
212
  const lambdaFunctionAlias = new lambda.Alias(scope, `${id}`, {
213
213
  ...props,
214
214
  ...{
215
- aliasName: `${id}-lambda-alias`,
215
+ aliasName: props.aliasName,
216
216
  version: lambdaVersion,
217
217
  additionalVersions: props.additionalVersions,
218
218
  description: props.description,
@@ -106,12 +106,19 @@ class SfnManager {
106
106
  createParallelStep(id, scope, props) {
107
107
  if (!props)
108
108
  throw `Step props undefined for ${id}`;
109
- return new sfn.Parallel(scope, `${props.name}`, {
109
+ const step = new sfn.Parallel(scope, `${props.name}`, {
110
110
  ...props,
111
111
  ...{
112
112
  comment: `Parallel step for ${props.name} - ${scope.props.stage} stage`,
113
113
  },
114
114
  });
115
+ if (props.retries && props.retries.length > 0) {
116
+ props.retries.forEach(retry => step.addRetry({
117
+ ...retry,
118
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
119
+ }));
120
+ }
121
+ return step;
115
122
  }
116
123
  /**
117
124
  * @summary Method to create a choice step
@@ -155,7 +162,7 @@ class SfnManager {
155
162
  createDynamoDbGetItemStep(id, scope, props, table, tableKey) {
156
163
  if (!props)
157
164
  throw `Step props undefined for ${id}`;
158
- return new tasks.DynamoGetItem(scope, `${props.name}`, {
165
+ const step = new tasks.DynamoGetItem(scope, `${props.name}`, {
159
166
  ...props,
160
167
  ...{
161
168
  table: table,
@@ -174,6 +181,13 @@ class SfnManager {
174
181
  comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
175
182
  },
176
183
  });
184
+ if (props.retries && props.retries.length > 0) {
185
+ props.retries.forEach(retry => step.addRetry({
186
+ ...retry,
187
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
188
+ }));
189
+ }
190
+ return step;
177
191
  }
178
192
  /**
179
193
  * @summary Method to create a DynamoDB put item step
@@ -186,7 +200,7 @@ class SfnManager {
186
200
  createDynamoDbPutItemStep(id, scope, props, table, tableItem) {
187
201
  if (!props)
188
202
  throw `Step props undefined for ${id}`;
189
- return new tasks.DynamoPutItem(scope, `${props.name}`, {
203
+ const step = new tasks.DynamoPutItem(scope, `${props.name}`, {
190
204
  ...props,
191
205
  ...{
192
206
  table: table,
@@ -207,6 +221,13 @@ class SfnManager {
207
221
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
208
222
  },
209
223
  });
224
+ if (props.retries && props.retries.length > 0) {
225
+ props.retries.forEach(retry => step.addRetry({
226
+ ...retry,
227
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
228
+ }));
229
+ }
230
+ return step;
210
231
  }
211
232
  /**
212
233
  * @summary Method to send a message to SQS step
@@ -220,7 +241,7 @@ class SfnManager {
220
241
  throw `Step props undefined for ${id}`;
221
242
  if (!props.messageBody)
222
243
  throw 'Message body undefined';
223
- return new tasks.SqsSendMessage(scope, `${props.name}`, {
244
+ const step = new tasks.SqsSendMessage(scope, `${props.name}`, {
224
245
  ...props,
225
246
  ...{
226
247
  queue: queue,
@@ -238,6 +259,13 @@ class SfnManager {
238
259
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
239
260
  },
240
261
  });
262
+ if (props.retries && props.retries.length > 0) {
263
+ props.retries.forEach(retry => step.addRetry({
264
+ ...retry,
265
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
266
+ }));
267
+ }
268
+ return step;
241
269
  }
242
270
  /**
243
271
  * @summary Method to create a lambda invoke step
@@ -249,13 +277,20 @@ class SfnManager {
249
277
  createLambdaStep(id, scope, props, lambdaFunction) {
250
278
  if (!props)
251
279
  throw `Step props undefined for ${id}`;
252
- return new tasks.LambdaInvoke(scope, `${props.name}`, {
280
+ const step = new tasks.LambdaInvoke(scope, `${props.name}`, {
253
281
  ...props,
254
282
  ...{
255
283
  lambdaFunction,
256
284
  comment: `Lambda step for ${props.name} - ${scope.props.stage} stage`,
257
285
  },
258
286
  });
287
+ if (props.retries && props.retries.length > 0) {
288
+ props.retries.forEach(retry => step.addRetry({
289
+ ...retry,
290
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
291
+ }));
292
+ }
293
+ return step;
259
294
  }
260
295
  /**
261
296
  * @summary Method to create a API Gateway invoke step
@@ -267,7 +302,7 @@ class SfnManager {
267
302
  createApiStep(id, scope, props, api) {
268
303
  if (!props)
269
304
  throw `Step props undefined for ${id}`;
270
- return new tasks.CallApiGatewayRestApiEndpoint(scope, `${props.name}`, {
305
+ const step = new tasks.CallApiGatewayRestApiEndpoint(scope, `${props.name}`, {
271
306
  ...props,
272
307
  ...{
273
308
  api,
@@ -275,6 +310,13 @@ class SfnManager {
275
310
  comment: `API step for ${props.name} - ${scope.props.stage} stage`,
276
311
  },
277
312
  });
313
+ if (props.retries && props.retries.length > 0) {
314
+ props.retries.forEach(retry => step.addRetry({
315
+ ...retry,
316
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
317
+ }));
318
+ }
319
+ return step;
278
320
  }
279
321
  /**
280
322
  * @summary Method to create a state machine
@@ -121,6 +121,13 @@ export interface KmsKeyProps extends kms.KeyProps {
121
121
  export interface SfnSucceedProps extends sfn.SucceedProps {
122
122
  name: string;
123
123
  }
124
+ /**
125
+ * @category cdk-utils.step-functions-manager
126
+ * @subcategory Properties
127
+ */
128
+ export interface SfnRetryProps extends sfn.RetryProps {
129
+ intervalInSecs: number;
130
+ }
124
131
  /**
125
132
  * @category cdk-utils.step-functions-manager
126
133
  * @subcategory Properties
@@ -141,6 +148,7 @@ export interface SfnPassProps extends sfn.PassProps {
141
148
  */
142
149
  export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
143
150
  name: string;
151
+ retries?: SfnRetryProps[];
144
152
  }
145
153
  /**
146
154
  * @category cdk-utils.step-functions-manager
@@ -148,6 +156,7 @@ export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
148
156
  */
149
157
  export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
150
158
  name: string;
159
+ retries?: SfnRetryProps[];
151
160
  }
152
161
  /**
153
162
  * @category cdk-utils.step-functions-manager
@@ -155,6 +164,7 @@ export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
155
164
  */
156
165
  export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
157
166
  name: string;
167
+ retries?: SfnRetryProps[];
158
168
  }
159
169
  /**
160
170
  * @category cdk-utils.step-functions-manager
@@ -162,6 +172,7 @@ export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
162
172
  */
163
173
  export interface SfnParallelProps extends sfn.ParallelProps {
164
174
  name: string;
175
+ retries?: SfnRetryProps[];
165
176
  }
166
177
  /**
167
178
  * @category cdk-utils.step-functions-manager
@@ -184,6 +195,7 @@ export interface SfnWaitProps extends sfn.WaitProps {
184
195
  */
185
196
  export interface SfnLambdaInvokeProps extends tasks.LambdaInvokeProps {
186
197
  name: string;
198
+ retries?: SfnRetryProps[];
187
199
  }
188
200
  /**
189
201
  * @category cdk-utils.step-functions-manager
@@ -191,6 +203,7 @@ export interface SfnLambdaInvokeProps extends tasks.LambdaInvokeProps {
191
203
  */
192
204
  export interface SfnCallApiGatewayRestApiEndpointProps extends tasks.CallApiGatewayRestApiEndpointProps {
193
205
  name: string;
206
+ retries?: SfnRetryProps[];
194
207
  }
195
208
  /**
196
209
  * @category cdk-utils.step-functions-manager
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.1.0",
3
+ "version": "8.3.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -263,7 +263,7 @@ export class LambdaManager {
263
263
  const lambdaFunctionAlias = new lambda.Alias(scope, `${id}`, {
264
264
  ...props,
265
265
  ...{
266
- aliasName: `${id}-lambda-alias`,
266
+ aliasName: props.aliasName,
267
267
  version: lambdaVersion,
268
268
  additionalVersions: props.additionalVersions,
269
269
  description: props.description,
@@ -88,12 +88,23 @@ export class SfnManager {
88
88
  */
89
89
  public createParallelStep(id: string, scope: common.CommonConstruct, props: types.SfnParallelProps) {
90
90
  if (!props) throw `Step props undefined for ${id}`
91
- return new sfn.Parallel(scope, `${props.name}`, {
91
+ const step = new sfn.Parallel(scope, `${props.name}`, {
92
92
  ...props,
93
93
  ...{
94
94
  comment: `Parallel step for ${props.name} - ${scope.props.stage} stage`,
95
95
  },
96
96
  })
97
+
98
+ if (props.retries && props.retries.length > 0) {
99
+ props.retries.forEach(retry =>
100
+ step.addRetry({
101
+ ...retry,
102
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
103
+ })
104
+ )
105
+ }
106
+
107
+ return step
97
108
  }
98
109
 
99
110
  /**
@@ -144,7 +155,7 @@ export class SfnManager {
144
155
  tableKey: { [key: string]: tasks.DynamoAttributeValue }
145
156
  ) {
146
157
  if (!props) throw `Step props undefined for ${id}`
147
- return new tasks.DynamoGetItem(scope, `${props.name}`, {
158
+ const step = new tasks.DynamoGetItem(scope, `${props.name}`, {
148
159
  ...props,
149
160
  ...{
150
161
  table: table,
@@ -163,6 +174,17 @@ export class SfnManager {
163
174
  comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
164
175
  },
165
176
  })
177
+
178
+ if (props.retries && props.retries.length > 0) {
179
+ props.retries.forEach(retry =>
180
+ step.addRetry({
181
+ ...retry,
182
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
183
+ })
184
+ )
185
+ }
186
+
187
+ return step
166
188
  }
167
189
 
168
190
  /**
@@ -181,7 +203,7 @@ export class SfnManager {
181
203
  tableItem: { [key: string]: tasks.DynamoAttributeValue }
182
204
  ) {
183
205
  if (!props) throw `Step props undefined for ${id}`
184
- return new tasks.DynamoPutItem(scope, `${props.name}`, {
206
+ const step = new tasks.DynamoPutItem(scope, `${props.name}`, {
185
207
  ...props,
186
208
  ...{
187
209
  table: table,
@@ -202,6 +224,17 @@ export class SfnManager {
202
224
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
203
225
  },
204
226
  })
227
+
228
+ if (props.retries && props.retries.length > 0) {
229
+ props.retries.forEach(retry =>
230
+ step.addRetry({
231
+ ...retry,
232
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
233
+ })
234
+ )
235
+ }
236
+
237
+ return step
205
238
  }
206
239
 
207
240
  /**
@@ -219,7 +252,7 @@ export class SfnManager {
219
252
  ) {
220
253
  if (!props) throw `Step props undefined for ${id}`
221
254
  if (!props.messageBody) throw 'Message body undefined'
222
- return new tasks.SqsSendMessage(scope, `${props.name}`, {
255
+ const step = new tasks.SqsSendMessage(scope, `${props.name}`, {
223
256
  ...props,
224
257
  ...{
225
258
  queue: queue,
@@ -237,6 +270,17 @@ export class SfnManager {
237
270
  comment: `DynamoDB PutItem step for ${props.name} - ${scope.props.stage} stage`,
238
271
  },
239
272
  })
273
+
274
+ if (props.retries && props.retries.length > 0) {
275
+ props.retries.forEach(retry =>
276
+ step.addRetry({
277
+ ...retry,
278
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
279
+ })
280
+ )
281
+ }
282
+
283
+ return step
240
284
  }
241
285
 
242
286
  /**
@@ -253,13 +297,24 @@ export class SfnManager {
253
297
  lambdaFunction: lambda.IFunction
254
298
  ) {
255
299
  if (!props) throw `Step props undefined for ${id}`
256
- return new tasks.LambdaInvoke(scope, `${props.name}`, {
300
+ const step = new tasks.LambdaInvoke(scope, `${props.name}`, {
257
301
  ...props,
258
302
  ...{
259
303
  lambdaFunction,
260
304
  comment: `Lambda step for ${props.name} - ${scope.props.stage} stage`,
261
305
  },
262
306
  })
307
+
308
+ if (props.retries && props.retries.length > 0) {
309
+ props.retries.forEach(retry =>
310
+ step.addRetry({
311
+ ...retry,
312
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
313
+ })
314
+ )
315
+ }
316
+
317
+ return step
263
318
  }
264
319
 
265
320
  /**
@@ -276,7 +331,7 @@ export class SfnManager {
276
331
  api: apig.IRestApi
277
332
  ) {
278
333
  if (!props) throw `Step props undefined for ${id}`
279
- return new tasks.CallApiGatewayRestApiEndpoint(scope, `${props.name}`, {
334
+ const step = new tasks.CallApiGatewayRestApiEndpoint(scope, `${props.name}`, {
280
335
  ...props,
281
336
  ...{
282
337
  api,
@@ -284,6 +339,17 @@ export class SfnManager {
284
339
  comment: `API step for ${props.name} - ${scope.props.stage} stage`,
285
340
  },
286
341
  })
342
+
343
+ if (props.retries && props.retries.length > 0) {
344
+ props.retries.forEach(retry =>
345
+ step.addRetry({
346
+ ...retry,
347
+ ...{ interval: retry.intervalInSecs ? cdk.Duration.seconds(retry.intervalInSecs) : retry.interval },
348
+ })
349
+ )
350
+ }
351
+
352
+ return step
287
353
  }
288
354
 
289
355
  /**
@@ -128,6 +128,14 @@ export interface SfnSucceedProps extends sfn.SucceedProps {
128
128
  name: string
129
129
  }
130
130
 
131
+ /**
132
+ * @category cdk-utils.step-functions-manager
133
+ * @subcategory Properties
134
+ */
135
+ export interface SfnRetryProps extends sfn.RetryProps {
136
+ intervalInSecs: number
137
+ }
138
+
131
139
  /**
132
140
  * @category cdk-utils.step-functions-manager
133
141
  * @subcategory Properties
@@ -150,6 +158,7 @@ export interface SfnPassProps extends sfn.PassProps {
150
158
  */
151
159
  export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
152
160
  name: string
161
+ retries?: SfnRetryProps[]
153
162
  }
154
163
 
155
164
  /**
@@ -158,6 +167,7 @@ export interface SfnDynamoGetItemProps extends tasks.DynamoGetItemProps {
158
167
  */
159
168
  export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
160
169
  name: string
170
+ retries?: SfnRetryProps[]
161
171
  }
162
172
 
163
173
  /**
@@ -166,6 +176,7 @@ export interface SfnDynamoPutItemProps extends tasks.DynamoPutItemProps {
166
176
  */
167
177
  export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
168
178
  name: string
179
+ retries?: SfnRetryProps[]
169
180
  }
170
181
 
171
182
  /**
@@ -174,6 +185,7 @@ export interface SfnSqsSendMessageProps extends tasks.SqsSendMessageProps {
174
185
  */
175
186
  export interface SfnParallelProps extends sfn.ParallelProps {
176
187
  name: string
188
+ retries?: SfnRetryProps[]
177
189
  }
178
190
 
179
191
  /**
@@ -199,6 +211,7 @@ export interface SfnWaitProps extends sfn.WaitProps {
199
211
  */
200
212
  export interface SfnLambdaInvokeProps extends tasks.LambdaInvokeProps {
201
213
  name: string
214
+ retries?: SfnRetryProps[]
202
215
  }
203
216
 
204
217
  /**
@@ -207,6 +220,7 @@ export interface SfnLambdaInvokeProps extends tasks.LambdaInvokeProps {
207
220
  */
208
221
  export interface SfnCallApiGatewayRestApiEndpointProps extends tasks.CallApiGatewayRestApiEndpointProps {
209
222
  name: string
223
+ retries?: SfnRetryProps[]
210
224
  }
211
225
 
212
226
  /**