@cumulus/aws-client 9.7.1 → 9.9.2
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/CloudFormation.js +10 -7
- package/CloudFormationGateway.js +2 -2
- package/CloudwatchEvents.js +8 -4
- package/DynamoDb.js +12 -11
- package/DynamoDbSearchQueue.d.ts +2 -2
- package/DynamoDbSearchQueue.js +1 -1
- package/KMS.js +8 -5
- package/Kinesis.js +3 -2
- package/Lambda.js +4 -3
- package/README.md +245 -237
- package/S3.d.ts +2 -2
- package/S3.js +111 -76
- package/S3ListObjectsV2Queue.js +1 -1
- package/S3ObjectStore.js +5 -5
- package/SNS.js +3 -2
- package/SQS.d.ts +6 -3
- package/SQS.js +31 -23
- package/SecretsManager.js +2 -1
- package/StepFunctions.d.ts +3 -1
- package/StepFunctions.js +15 -12
- package/client.js +2 -2
- package/index.js +2 -1
- package/lib/S3MultipartUploads.js +11 -6
- package/package.json +5 -5
- package/services.js +1 -1
- package/test-utils.js +4 -2
- package/utils.js +8 -5
package/CloudFormation.js
CHANGED
|
@@ -17,12 +17,13 @@ const services_1 = require("./services");
|
|
|
17
17
|
* @param {string} StackName - The name of the CloudFormation stack to query
|
|
18
18
|
* @returns {Promise<CloudFormation.Stack>} The resources belonging to the stack
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
const response = await services_1.cf().describeStacks({ StackName }).promise();
|
|
20
|
+
const describeCfStack = async (StackName) => {
|
|
21
|
+
const response = await (0, services_1.cf)().describeStacks({ StackName }).promise();
|
|
22
22
|
if (response.Stacks)
|
|
23
23
|
return response.Stacks[0];
|
|
24
24
|
throw new Error(`Stack not found: ${StackName}`);
|
|
25
25
|
};
|
|
26
|
+
exports.describeCfStack = describeCfStack;
|
|
26
27
|
/**
|
|
27
28
|
* Describes the resources belonging to a given CloudFormation stack
|
|
28
29
|
*
|
|
@@ -31,10 +32,11 @@ exports.describeCfStack = async (StackName) => {
|
|
|
31
32
|
* @param {string} StackName - The name of the CloudFormation stack to query
|
|
32
33
|
* @returns {Promise<CloudFormation.StackResources>} The resources belonging to the stack
|
|
33
34
|
*/
|
|
34
|
-
|
|
35
|
-
const response = await services_1.cf().describeStackResources({ StackName }).promise();
|
|
35
|
+
const describeCfStackResources = async (StackName) => {
|
|
36
|
+
const response = await (0, services_1.cf)().describeStackResources({ StackName }).promise();
|
|
36
37
|
return response.StackResources;
|
|
37
38
|
};
|
|
39
|
+
exports.describeCfStackResources = describeCfStackResources;
|
|
38
40
|
/**
|
|
39
41
|
* Get parameter values for the given CloudFormation stack
|
|
40
42
|
*
|
|
@@ -42,10 +44,10 @@ exports.describeCfStackResources = async (StackName) => {
|
|
|
42
44
|
* @param {Array<string>} parameterKeys - Key names for the stack parameters that you want to return
|
|
43
45
|
* @returns {Promise<Object>} Object keyed by parameter names
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
const getCfStackParameterValues = async (stackName, parameterKeys) => {
|
|
46
48
|
let response;
|
|
47
49
|
try {
|
|
48
|
-
response = await exports.describeCfStack(stackName);
|
|
50
|
+
response = await (0, exports.describeCfStack)(stackName);
|
|
49
51
|
}
|
|
50
52
|
catch (error) {
|
|
51
53
|
return {};
|
|
@@ -55,6 +57,7 @@ exports.getCfStackParameterValues = async (stackName, parameterKeys) => {
|
|
|
55
57
|
return { ...acc, [ParameterKey]: ParameterValue };
|
|
56
58
|
return acc;
|
|
57
59
|
}, {});
|
|
58
|
-
return pick_1.default(parameters, parameterKeys);
|
|
60
|
+
return (0, pick_1.default)(parameters, parameterKeys);
|
|
59
61
|
};
|
|
62
|
+
exports.getCfStackParameterValues = getCfStackParameterValues;
|
|
60
63
|
//# sourceMappingURL=CloudFormation.js.map
|
package/CloudFormationGateway.js
CHANGED
|
@@ -17,7 +17,7 @@ class CloudFormationGateway {
|
|
|
17
17
|
* @returns {string} the stack status
|
|
18
18
|
*/
|
|
19
19
|
async getStackStatus(StackName) {
|
|
20
|
-
return await p_retry_1.default(async () => {
|
|
20
|
+
return await (0, p_retry_1.default)(async () => {
|
|
21
21
|
try {
|
|
22
22
|
const stackDetails = await this.cloudFormationService.describeStacks({
|
|
23
23
|
StackName,
|
|
@@ -28,7 +28,7 @@ class CloudFormationGateway {
|
|
|
28
28
|
return stackDetails.Stacks[0].StackStatus;
|
|
29
29
|
}
|
|
30
30
|
catch (error) {
|
|
31
|
-
if (errors_1.isThrottlingException(error))
|
|
31
|
+
if ((0, errors_1.isThrottlingException)(error))
|
|
32
32
|
throw new Error('Trigger retry');
|
|
33
33
|
throw new p_retry_1.default.AbortError(error);
|
|
34
34
|
}
|
package/CloudwatchEvents.js
CHANGED
|
@@ -15,19 +15,22 @@ const services_1 = require("./services");
|
|
|
15
15
|
* @param {string} [role] - a Role ARN
|
|
16
16
|
* @returns {Promise<CloudWatchEvents.PutRuleResponse>}
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
const putEvent = (name, schedule, state, description, role) => (0, services_1.cloudwatchevents)().putRule({
|
|
19
19
|
Name: name,
|
|
20
20
|
Description: description,
|
|
21
21
|
RoleArn: role,
|
|
22
22
|
ScheduleExpression: schedule,
|
|
23
23
|
State: state,
|
|
24
24
|
}).promise();
|
|
25
|
-
exports.
|
|
26
|
-
|
|
25
|
+
exports.putEvent = putEvent;
|
|
26
|
+
const deleteEvent = (name) => (0, services_1.cloudwatchevents)().deleteRule({ Name: name }).promise();
|
|
27
|
+
exports.deleteEvent = deleteEvent;
|
|
28
|
+
const deleteTarget = (id, rule) => (0, services_1.cloudwatchevents)().removeTargets({
|
|
27
29
|
Ids: [id],
|
|
28
30
|
Rule: rule,
|
|
29
31
|
}).promise();
|
|
30
|
-
exports.
|
|
32
|
+
exports.deleteTarget = deleteTarget;
|
|
33
|
+
const putTarget = (rule, id, arn, input) => (0, services_1.cloudwatchevents)().putTargets({
|
|
31
34
|
Rule: rule,
|
|
32
35
|
Targets: [
|
|
33
36
|
{
|
|
@@ -37,4 +40,5 @@ exports.putTarget = (rule, id, arn, input) => services_1.cloudwatchevents().putT
|
|
|
37
40
|
},
|
|
38
41
|
],
|
|
39
42
|
}).promise();
|
|
43
|
+
exports.putTarget = putTarget;
|
|
40
44
|
//# sourceMappingURL=CloudwatchEvents.js.map
|
package/DynamoDb.js
CHANGED
|
@@ -27,7 +27,7 @@ const utils_1 = require("./utils");
|
|
|
27
27
|
* @returns {Promise<Object>}
|
|
28
28
|
* @throws {RecordDoesNotExist} if a record cannot be found
|
|
29
29
|
*/
|
|
30
|
-
exports.get = utils_1.improveStackTrace(async (params) => {
|
|
30
|
+
exports.get = (0, utils_1.improveStackTrace)(async (params) => {
|
|
31
31
|
const { client, getParams = {}, item, tableName, } = params;
|
|
32
32
|
const getResponse = await client.get({
|
|
33
33
|
...getParams,
|
|
@@ -47,7 +47,7 @@ exports.get = utils_1.improveStackTrace(async (params) => {
|
|
|
47
47
|
* @param {Object} params
|
|
48
48
|
* @returns {Promise<Object>}
|
|
49
49
|
*/
|
|
50
|
-
exports.scan = utils_1.improveStackTrace(async (params) => {
|
|
50
|
+
exports.scan = (0, utils_1.improveStackTrace)(async (params) => {
|
|
51
51
|
const { client, fields, limit, query, select, startKey, tableName, } = params;
|
|
52
52
|
const scanParams = {
|
|
53
53
|
TableName: tableName,
|
|
@@ -76,7 +76,7 @@ exports.scan = utils_1.improveStackTrace(async (params) => {
|
|
|
76
76
|
const response = await client.scan(scanParams).promise();
|
|
77
77
|
// recursively go through all the records
|
|
78
78
|
if (response.LastEvaluatedKey) {
|
|
79
|
-
const more = await exports.scan({
|
|
79
|
+
const more = await (0, exports.scan)({
|
|
80
80
|
tableName,
|
|
81
81
|
client,
|
|
82
82
|
query,
|
|
@@ -111,9 +111,9 @@ exports.scan = utils_1.improveStackTrace(async (params) => {
|
|
|
111
111
|
* @param {pRetry.Options} [params.retryOptions] - Retry options for scan operations
|
|
112
112
|
* @returns {Promise}
|
|
113
113
|
*/
|
|
114
|
-
|
|
115
|
-
const { totalSegments, scanParams, processItemsFunc, dynamoDbClient = services_1.dynamodbDocClient(), retryOptions, } = params;
|
|
116
|
-
return await p_map_1.default(range_1.default(totalSegments), async (_, segmentIndex) => {
|
|
114
|
+
const parallelScan = async (params) => {
|
|
115
|
+
const { totalSegments, scanParams, processItemsFunc, dynamoDbClient = (0, services_1.dynamodbDocClient)(), retryOptions, } = params;
|
|
116
|
+
return await (0, p_map_1.default)((0, range_1.default)(totalSegments), async (_, segmentIndex) => {
|
|
117
117
|
let exclusiveStartKey;
|
|
118
118
|
const segmentScanParams = {
|
|
119
119
|
...scanParams,
|
|
@@ -122,7 +122,7 @@ exports.parallelScan = async (params) => {
|
|
|
122
122
|
};
|
|
123
123
|
/* eslint-disable no-await-in-loop */
|
|
124
124
|
do {
|
|
125
|
-
const { Items = [], LastEvaluatedKey, } = await p_retry_1.default(() => dynamoDbClient.scan(segmentScanParams).promise(), retryOptions);
|
|
125
|
+
const { Items = [], LastEvaluatedKey, } = await (0, p_retry_1.default)(() => dynamoDbClient.scan(segmentScanParams).promise(), retryOptions);
|
|
126
126
|
exclusiveStartKey = LastEvaluatedKey;
|
|
127
127
|
segmentScanParams.ExclusiveStartKey = exclusiveStartKey;
|
|
128
128
|
await processItemsFunc(Items);
|
|
@@ -133,6 +133,7 @@ exports.parallelScan = async (params) => {
|
|
|
133
133
|
stopOnError: false,
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
|
+
exports.parallelScan = parallelScan;
|
|
136
137
|
/**
|
|
137
138
|
* Create a DynamoDB table and then wait for the table to exist
|
|
138
139
|
*
|
|
@@ -143,8 +144,8 @@ exports.parallelScan = async (params) => {
|
|
|
143
144
|
* @static
|
|
144
145
|
*/
|
|
145
146
|
async function createAndWaitForDynamoDbTable(params) {
|
|
146
|
-
const createTableResult = await services_1.dynamodb().createTable(params).promise();
|
|
147
|
-
await services_1.dynamodb().waitFor('tableExists', { TableName: params.TableName }).promise();
|
|
147
|
+
const createTableResult = await (0, services_1.dynamodb)().createTable(params).promise();
|
|
148
|
+
await (0, services_1.dynamodb)().waitFor('tableExists', { TableName: params.TableName }).promise();
|
|
148
149
|
return createTableResult;
|
|
149
150
|
}
|
|
150
151
|
exports.createAndWaitForDynamoDbTable = createAndWaitForDynamoDbTable;
|
|
@@ -158,8 +159,8 @@ exports.createAndWaitForDynamoDbTable = createAndWaitForDynamoDbTable;
|
|
|
158
159
|
* @static
|
|
159
160
|
*/
|
|
160
161
|
async function deleteAndWaitForDynamoDbTableNotExists(params) {
|
|
161
|
-
await services_1.dynamodb().deleteTable(params).promise();
|
|
162
|
-
return services_1.dynamodb().waitFor('tableNotExists', { TableName: params.TableName }).promise();
|
|
162
|
+
await (0, services_1.dynamodb)().deleteTable(params).promise();
|
|
163
|
+
return (0, services_1.dynamodb)().waitFor('tableNotExists', { TableName: params.TableName }).promise();
|
|
163
164
|
}
|
|
164
165
|
exports.deleteAndWaitForDynamoDbTableNotExists = deleteAndWaitForDynamoDbTableNotExists;
|
|
165
166
|
//# sourceMappingURL=DynamoDb.js.map
|
package/DynamoDbSearchQueue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as AWS from 'aws-sdk';
|
|
2
|
-
declare type
|
|
2
|
+
declare type SearchType = 'scan' | 'query';
|
|
3
3
|
/**
|
|
4
4
|
* Class to efficiently search all of the items in a DynamoDB table, without loading them all into
|
|
5
5
|
* memory at once. Handles paging.
|
|
@@ -9,7 +9,7 @@ declare class DynamoDbSearchQueue {
|
|
|
9
9
|
private readonly searchType;
|
|
10
10
|
private readonly params;
|
|
11
11
|
private items;
|
|
12
|
-
constructor(params: AWS.DynamoDB.DocumentClient.ScanInput, searchType?:
|
|
12
|
+
constructor(params: AWS.DynamoDB.DocumentClient.ScanInput, searchType?: SearchType);
|
|
13
13
|
/**
|
|
14
14
|
* Drain all values from the searchQueue, and return to the user.
|
|
15
15
|
* Warning: This can be very memory intensive.
|
package/DynamoDbSearchQueue.js
CHANGED
|
@@ -8,7 +8,7 @@ class DynamoDbSearchQueue {
|
|
|
8
8
|
constructor(params, searchType = 'scan') {
|
|
9
9
|
this.items = [];
|
|
10
10
|
this.params = params;
|
|
11
|
-
this.dynamodbDocClient = services_1.dynamodbDocClient();
|
|
11
|
+
this.dynamodbDocClient = (0, services_1.dynamodbDocClient)();
|
|
12
12
|
this.searchType = searchType;
|
|
13
13
|
}
|
|
14
14
|
/**
|
package/KMS.js
CHANGED
|
@@ -14,7 +14,8 @@ const services_1 = require("./services");
|
|
|
14
14
|
* @param {Object} params
|
|
15
15
|
* @returns {Promise<Object>}
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
const createKey = (params = {}) => (0, services_1.kms)().createKey(params).promise();
|
|
18
|
+
exports.createKey = createKey;
|
|
18
19
|
/**
|
|
19
20
|
* Encrypt a string using KMS
|
|
20
21
|
*
|
|
@@ -22,24 +23,26 @@ exports.createKey = (params = {}) => services_1.kms().createKey(params).promise(
|
|
|
22
23
|
* @param {string} Plaintext - the string to be encrypted
|
|
23
24
|
* @returns {Promise<string>} the Base 64 encoding of the encrypted value
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
const { CiphertextBlob } = await services_1.kms().encrypt({ KeyId, Plaintext }).promise();
|
|
26
|
+
const encrypt = async (KeyId, Plaintext) => {
|
|
27
|
+
const { CiphertextBlob } = await (0, services_1.kms)().encrypt({ KeyId, Plaintext }).promise();
|
|
27
28
|
if (CiphertextBlob === undefined)
|
|
28
29
|
throw new Error('Returned CiphertextBlob is undefined');
|
|
29
30
|
return CiphertextBlob.toString('base64');
|
|
30
31
|
};
|
|
32
|
+
exports.encrypt = encrypt;
|
|
31
33
|
/**
|
|
32
34
|
* Decrypt a KMS-encrypted string, Base 64 encoded
|
|
33
35
|
*
|
|
34
36
|
* @param {string} ciphertext - a KMS-encrypted value, Base 64 encoded
|
|
35
37
|
* @returns {string} the plaintext
|
|
36
38
|
*/
|
|
37
|
-
|
|
38
|
-
const { Plaintext } = await services_1.kms().decrypt({
|
|
39
|
+
const decryptBase64String = async (ciphertext) => {
|
|
40
|
+
const { Plaintext } = await (0, services_1.kms)().decrypt({
|
|
39
41
|
CiphertextBlob: Buffer.from(ciphertext, 'base64'),
|
|
40
42
|
}).promise();
|
|
41
43
|
if (Plaintext === undefined)
|
|
42
44
|
return undefined;
|
|
43
45
|
return Plaintext.toString();
|
|
44
46
|
};
|
|
47
|
+
exports.decryptBase64String = decryptBase64String;
|
|
45
48
|
//# sourceMappingURL=KMS.js.map
|
package/Kinesis.js
CHANGED
|
@@ -17,9 +17,9 @@ const services_1 = require("./services");
|
|
|
17
17
|
* @param {Object} retryOptions - Options passed to p-retry module
|
|
18
18
|
* @returns {Promise<Object>} The stream description response
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
const describeStream = (params, retryOptions = { retries: 0 }) => (0, p_retry_1.default)(async () => {
|
|
21
21
|
try {
|
|
22
|
-
return await services_1.kinesis().describeStream(params).promise();
|
|
22
|
+
return await (0, services_1.kinesis)().describeStream(params).promise();
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
25
|
if (error.code === 'ResourceNotFoundException')
|
|
@@ -27,4 +27,5 @@ exports.describeStream = (params, retryOptions = { retries: 0 }) => p_retry_1.de
|
|
|
27
27
|
throw new p_retry_1.default.AbortError(error);
|
|
28
28
|
}
|
|
29
29
|
}, { maxTimeout: 10000, ...retryOptions });
|
|
30
|
+
exports.describeStream = describeStream;
|
|
30
31
|
//# sourceMappingURL=Kinesis.js.map
|
package/Lambda.js
CHANGED
|
@@ -21,13 +21,13 @@ const log = new logger_1.default({ sender: 'aws-client/Lambda' });
|
|
|
21
21
|
*
|
|
22
22
|
* @alias module:Lambda.invoke
|
|
23
23
|
*/
|
|
24
|
-
|
|
25
|
-
if (process.env.IS_LOCAL || test_utils_1.inTestMode()) {
|
|
24
|
+
const invoke = async (name, payload, type = 'Event') => {
|
|
25
|
+
if (process.env.IS_LOCAL || (0, test_utils_1.inTestMode)()) {
|
|
26
26
|
log.info(`Faking Lambda invocation for ${name}`);
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
log.info(`Invoking ${name}`);
|
|
30
|
-
return await services_1.lambda().invoke({
|
|
30
|
+
return await (0, services_1.lambda)().invoke({
|
|
31
31
|
FunctionName: name,
|
|
32
32
|
Payload: JSON.stringify(payload),
|
|
33
33
|
InvocationType: type,
|
|
@@ -35,4 +35,5 @@ exports.invoke = async (name, payload, type = 'Event') => {
|
|
|
35
35
|
.on('error', (error) => log.error(`Error invoking ${name}`, error))
|
|
36
36
|
.promise();
|
|
37
37
|
};
|
|
38
|
+
exports.invoke = invoke;
|
|
38
39
|
//# sourceMappingURL=Lambda.js.map
|