@gradientedge/cdk-utils 6.16.0 → 7.0.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/manager/aws/sfn-manager.d.ts +14 -2
- package/dist/src/lib/manager/aws/sfn-manager.js +22 -0
- package/dist/src/lib/manager/aws/vpc-manager.js +1 -1
- package/dist/src/lib/types/aws/index.d.ts +7 -0
- package/package.json +14 -13
- package/src/lib/manager/aws/sfn-manager.ts +30 -2
- package/src/lib/manager/aws/vpc-manager.ts +1 -1
- package/src/lib/types/aws/index.ts +8 -0
|
@@ -1,12 +1,13 @@
|
|
|
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';
|
|
6
7
|
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';
|
|
8
|
+
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks';
|
|
7
9
|
import * as common from '../../common';
|
|
8
10
|
import * as types from '../../types';
|
|
9
|
-
import { SfnStateMachineProps } from '../../types';
|
|
10
11
|
/**
|
|
11
12
|
* @stability stable
|
|
12
13
|
* @category cdk-utils.step-functions-manager
|
|
@@ -70,6 +71,17 @@ export declare class SfnManager {
|
|
|
70
71
|
* @param {types.SfnWaitProps} props
|
|
71
72
|
*/
|
|
72
73
|
createWaitStep(id: string, scope: common.CommonConstruct, props: types.SfnWaitProps): cdk.aws_stepfunctions.Wait;
|
|
74
|
+
/**
|
|
75
|
+
* @summary Method to create a DynamoDB get item step
|
|
76
|
+
* @param {string} id scoped id of the resource
|
|
77
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
78
|
+
* @param {types.SfnPassProps} props
|
|
79
|
+
* @param {dynamodb.ITable} table
|
|
80
|
+
* @param tableKey
|
|
81
|
+
*/
|
|
82
|
+
createDynamoDbGetItemStep(id: string, scope: common.CommonConstruct, props: types.SfnDynamoGetItemProps, table: dynamodb.ITable, tableKey: {
|
|
83
|
+
[key: string]: tasks.DynamoAttributeValue;
|
|
84
|
+
}): cdk.aws_stepfunctions_tasks.DynamoGetItem;
|
|
73
85
|
/**
|
|
74
86
|
* @summary Method to create a lambda invoke step
|
|
75
87
|
* @param {string} id scoped id of the resource
|
|
@@ -95,5 +107,5 @@ export declare class SfnManager {
|
|
|
95
107
|
* @param {logs.ILogGroup} logGroup
|
|
96
108
|
* @param {iam.IRole} role
|
|
97
109
|
*/
|
|
98
|
-
createStateMachine(id: string, scope: common.CommonConstruct, props: SfnStateMachineProps, definition: sfn.IChainable, logGroup: logs.ILogGroup, role?: iam.IRole): cdk.aws_stepfunctions.StateMachine;
|
|
110
|
+
createStateMachine(id: string, scope: common.CommonConstruct, props: types.SfnStateMachineProps, definition: sfn.IChainable, logGroup: logs.ILogGroup, role?: iam.IRole): cdk.aws_stepfunctions.StateMachine;
|
|
99
111
|
}
|
|
@@ -144,6 +144,28 @@ 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.SfnPassProps} props
|
|
152
|
+
* @param {dynamodb.ITable} table
|
|
153
|
+
* @param tableKey
|
|
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
|
+
resultPath: props.resultPath,
|
|
165
|
+
comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
147
169
|
/**
|
|
148
170
|
* @summary Method to create a lambda invoke step
|
|
149
171
|
* @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
|
-
|
|
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,13 @@ 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
|
+
}
|
|
138
145
|
/**
|
|
139
146
|
* @category cdk-utils.step-functions-manager
|
|
140
147
|
* @subcategory Properties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.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.
|
|
49
|
-
"@types/node": "^18.11.
|
|
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.
|
|
52
|
-
"aws-sdk": "^2.
|
|
53
|
-
"constructs": "^10.1.
|
|
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.
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
64
|
-
"@typescript-eslint/parser": "^5.
|
|
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.
|
|
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.
|
|
75
|
+
"jest": "^29.2.2",
|
|
76
76
|
"jest-extended": "^3.1.0",
|
|
77
77
|
"jest-junit": "^14.0.1",
|
|
78
|
-
"jsdoc": "^
|
|
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.
|
|
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,5 +1,6 @@
|
|
|
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,7 +8,6 @@ import * as sfn from 'aws-cdk-lib/aws-stepfunctions'
|
|
|
7
8
|
import * as tasks from 'aws-cdk-lib/aws-stepfunctions-tasks'
|
|
8
9
|
import * as common from '../../common'
|
|
9
10
|
import * as types from '../../types'
|
|
10
|
-
import { SfnStateMachineProps } from '../../types'
|
|
11
11
|
import * as utils from '../../utils'
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -127,6 +127,34 @@ export class SfnManager {
|
|
|
127
127
|
})
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @summary Method to create a DynamoDB get item step
|
|
132
|
+
* @param {string} id scoped id of the resource
|
|
133
|
+
* @param {common.CommonConstruct} scope scope in which this resource is defined
|
|
134
|
+
* @param {types.SfnPassProps} props
|
|
135
|
+
* @param {dynamodb.ITable} table
|
|
136
|
+
* @param tableKey
|
|
137
|
+
*/
|
|
138
|
+
public createDynamoDbGetItemStep(
|
|
139
|
+
id: string,
|
|
140
|
+
scope: common.CommonConstruct,
|
|
141
|
+
props: types.SfnDynamoGetItemProps,
|
|
142
|
+
table: dynamodb.ITable,
|
|
143
|
+
tableKey: { [key: string]: tasks.DynamoAttributeValue }
|
|
144
|
+
) {
|
|
145
|
+
if (!props) throw 'Step props undefined'
|
|
146
|
+
return new tasks.DynamoGetItem(scope, `${props.name}`, {
|
|
147
|
+
...props,
|
|
148
|
+
...{
|
|
149
|
+
table: table,
|
|
150
|
+
key: tableKey,
|
|
151
|
+
consistentRead: props.consistentRead,
|
|
152
|
+
resultPath: props.resultPath,
|
|
153
|
+
comment: `DynamoDB GetItem step for ${props.name} - ${scope.props.stage} stage`,
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
|
|
130
158
|
/**
|
|
131
159
|
* @summary Method to create a lambda invoke step
|
|
132
160
|
* @param {string} id scoped id of the resource
|
|
@@ -186,7 +214,7 @@ export class SfnManager {
|
|
|
186
214
|
public createStateMachine(
|
|
187
215
|
id: string,
|
|
188
216
|
scope: common.CommonConstruct,
|
|
189
|
-
props: SfnStateMachineProps,
|
|
217
|
+
props: types.SfnStateMachineProps,
|
|
190
218
|
definition: sfn.IChainable,
|
|
191
219
|
logGroup: logs.ILogGroup,
|
|
192
220
|
role?: iam.IRole
|
|
@@ -144,6 +144,14 @@ 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
|
+
|
|
147
155
|
/**
|
|
148
156
|
* @category cdk-utils.step-functions-manager
|
|
149
157
|
* @subcategory Properties
|