@gradientedge/cdk-utils 7.0.0 → 7.2.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/ecs-manager.d.ts +2 -1
- package/dist/src/lib/manager/aws/ecs-manager.js +3 -1
- package/dist/src/lib/manager/aws/sfn-manager.d.ts +23 -3
- package/dist/src/lib/manager/aws/sfn-manager.js +76 -3
- package/dist/src/lib/types/aws/index.d.ts +14 -0
- package/package.json +1 -1
- package/src/lib/manager/aws/ecs-manager.ts +4 -1
- package/src/lib/manager/aws/sfn-manager.ts +87 -3
- package/src/lib/types/aws/index.ts +16 -0
|
@@ -43,6 +43,7 @@ export declare class EcsManager {
|
|
|
43
43
|
* @param {logs.ILogGroup} logGroup
|
|
44
44
|
* @param {ecs.ContainerImage} containerImage
|
|
45
45
|
* @param {Map<string, string>} environment
|
|
46
|
+
* @param {Map<string, string>} secrets
|
|
46
47
|
*/
|
|
47
|
-
createEcsFargateTask(id: string, scope: common.CommonConstruct, props: types.EcsTaskProps, cluster: ecs.ICluster, role: iam.Role, logGroup: logs.ILogGroup, containerImage: ecs.ContainerImage, environment?: any): ecs.TaskDefinition;
|
|
48
|
+
createEcsFargateTask(id: string, scope: common.CommonConstruct, props: types.EcsTaskProps, cluster: ecs.ICluster, role: iam.Role, logGroup: logs.ILogGroup, containerImage: ecs.ContainerImage, environment?: any, secrets?: any): ecs.TaskDefinition;
|
|
48
49
|
}
|
|
@@ -80,8 +80,9 @@ class EcsManager {
|
|
|
80
80
|
* @param {logs.ILogGroup} logGroup
|
|
81
81
|
* @param {ecs.ContainerImage} containerImage
|
|
82
82
|
* @param {Map<string, string>} environment
|
|
83
|
+
* @param {Map<string, string>} secrets
|
|
83
84
|
*/
|
|
84
|
-
createEcsFargateTask(id, scope, props, cluster, role, logGroup, containerImage, environment) {
|
|
85
|
+
createEcsFargateTask(id, scope, props, cluster, role, logGroup, containerImage, environment, secrets) {
|
|
85
86
|
if (!props)
|
|
86
87
|
throw `EcsTask props undefined`;
|
|
87
88
|
const ecsTask = new ecs.TaskDefinition(scope, `${id}`, {
|
|
@@ -104,6 +105,7 @@ class EcsManager {
|
|
|
104
105
|
}),
|
|
105
106
|
memoryLimitMiB: props.memoryMiB ? parseInt(props.memoryMiB) : undefined,
|
|
106
107
|
privileged: false,
|
|
108
|
+
secrets: secrets,
|
|
107
109
|
});
|
|
108
110
|
utils.createCfnOutput(`${id}-taskArn`, scope, ecsTask.taskDefinitionArn);
|
|
109
111
|
return ecsTask;
|
|
@@ -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.
|
|
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.
|
|
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
|
@@ -63,6 +63,7 @@ export class EcsManager {
|
|
|
63
63
|
* @param {logs.ILogGroup} logGroup
|
|
64
64
|
* @param {ecs.ContainerImage} containerImage
|
|
65
65
|
* @param {Map<string, string>} environment
|
|
66
|
+
* @param {Map<string, string>} secrets
|
|
66
67
|
*/
|
|
67
68
|
public createEcsFargateTask(
|
|
68
69
|
id: string,
|
|
@@ -72,7 +73,8 @@ export class EcsManager {
|
|
|
72
73
|
role: iam.Role,
|
|
73
74
|
logGroup: logs.ILogGroup,
|
|
74
75
|
containerImage: ecs.ContainerImage,
|
|
75
|
-
environment?: any
|
|
76
|
+
environment?: any,
|
|
77
|
+
secrets?: any
|
|
76
78
|
) {
|
|
77
79
|
if (!props) throw `EcsTask props undefined`
|
|
78
80
|
|
|
@@ -97,6 +99,7 @@ export class EcsManager {
|
|
|
97
99
|
}),
|
|
98
100
|
memoryLimitMiB: props.memoryMiB ? parseInt(props.memoryMiB) : undefined,
|
|
99
101
|
privileged: false,
|
|
102
|
+
secrets: secrets,
|
|
100
103
|
})
|
|
101
104
|
|
|
102
105
|
utils.createCfnOutput(`${id}-taskArn`, scope, ecsTask.taskDefinitionArn)
|
|
@@ -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.
|
|
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
|