@dmptool/utils 1.0.35 → 1.0.36
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/ssm.d.ts +8 -4
- package/dist/ssm.js +8 -10
- package/package.json +9 -9
package/dist/ssm.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { EnvironmentEnum } from "./general";
|
|
2
2
|
import { Logger } from 'pino';
|
|
3
|
+
export interface SsmConnectionParams {
|
|
4
|
+
logger: Logger;
|
|
5
|
+
region: string;
|
|
6
|
+
useTLS?: boolean;
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
}
|
|
3
9
|
/**
|
|
4
10
|
* Retrieve a variable from the SSM Parameter store.
|
|
5
11
|
*
|
|
6
|
-
* @param
|
|
12
|
+
* @param connectionParams The connection parameters to use for the SSM client.
|
|
7
13
|
* @param key The name of the variable to retrieve.
|
|
8
14
|
* @param env The environment to retrieve the variable from. Defaults to `EnvironmentEnum.DEV`.
|
|
9
|
-
* @param region The region to retrieve the variable from. Defaults to 'us-west-2'.
|
|
10
|
-
* @param useTLS Whether to use TLS when connecting to the SSM Parameter store. Defaults to true.
|
|
11
15
|
* Should be false when running in a local development environment.
|
|
12
16
|
* @returns The value of the variable, or undefined if the variable could not be found.
|
|
13
17
|
* @throws
|
|
14
18
|
*/
|
|
15
|
-
export declare const getSSMParameter: (
|
|
19
|
+
export declare const getSSMParameter: (connectionParams: SsmConnectionParams, key: string, env?: EnvironmentEnum, endpoint?: string) => Promise<string | undefined>;
|
package/dist/ssm.js
CHANGED
|
@@ -6,24 +6,22 @@ const client_ssm_1 = require("@aws-sdk/client-ssm");
|
|
|
6
6
|
/**
|
|
7
7
|
* Retrieve a variable from the SSM Parameter store.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param connectionParams The connection parameters to use for the SSM client.
|
|
10
10
|
* @param key The name of the variable to retrieve.
|
|
11
11
|
* @param env The environment to retrieve the variable from. Defaults to `EnvironmentEnum.DEV`.
|
|
12
|
-
* @param region The region to retrieve the variable from. Defaults to 'us-west-2'.
|
|
13
|
-
* @param useTLS Whether to use TLS when connecting to the SSM Parameter store. Defaults to true.
|
|
14
12
|
* Should be false when running in a local development environment.
|
|
15
13
|
* @returns The value of the variable, or undefined if the variable could not be found.
|
|
16
14
|
* @throws
|
|
17
15
|
*/
|
|
18
|
-
const getSSMParameter = async (
|
|
16
|
+
const getSSMParameter = async (connectionParams, key, env = general_1.EnvironmentEnum.DEV, endpoint) => {
|
|
19
17
|
var _a;
|
|
20
|
-
if (logger && key && key.trim() !== '') {
|
|
18
|
+
if (connectionParams.logger && key && key.trim() !== '') {
|
|
21
19
|
// Create an SSM client (use the endpoint if we are not using TLS - local dev)
|
|
22
|
-
const client = useTLS
|
|
20
|
+
const client = connectionParams.useTLS
|
|
23
21
|
? new client_ssm_1.SSMClient()
|
|
24
|
-
: new client_ssm_1.SSMClient(
|
|
22
|
+
: new client_ssm_1.SSMClient(connectionParams);
|
|
25
23
|
const keyPrefix = `/uc3/dmp/tool/${env.toLowerCase()}/`;
|
|
26
|
-
logger.debug(`Fetching parameter ${keyPrefix}${key}`);
|
|
24
|
+
connectionParams.logger.debug(`Fetching parameter ${keyPrefix}${key}`);
|
|
27
25
|
try {
|
|
28
26
|
const command = new client_ssm_1.GetParameterCommand({
|
|
29
27
|
Name: `${keyPrefix}${key}`,
|
|
@@ -33,10 +31,10 @@ const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV,
|
|
|
33
31
|
if (!(0, general_1.isNullOrUndefined)(response) && !(0, general_1.isNullOrUndefined)(response.Parameter)) {
|
|
34
32
|
return (_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value;
|
|
35
33
|
}
|
|
36
|
-
logger.warn(`Parameter ${keyPrefix}${key} not found.`);
|
|
34
|
+
connectionParams.logger.warn(`Parameter ${keyPrefix}${key} not found.`);
|
|
37
35
|
}
|
|
38
36
|
catch (error) {
|
|
39
|
-
logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
|
|
37
|
+
connectionParams.logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dmptool/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.36",
|
|
4
4
|
"description": "Helper/Utility functions for use in the DMP Tool services. Particularly AWS tooling and maDMP serialization",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"pino-lambda": "^4.4.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@aws-sdk/client-cloudformation": "^3.
|
|
45
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
46
|
-
"@aws-sdk/client-sqs": "^3.
|
|
47
|
-
"@aws-sdk/client-s3": "^3.
|
|
48
|
-
"@aws-sdk/client-sns": "^3.
|
|
49
|
-
"@aws-sdk/client-ssm": "^3.
|
|
50
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
51
|
-
"@aws-sdk/util-dynamodb": "^3.
|
|
44
|
+
"@aws-sdk/client-cloudformation": "^3.980.0",
|
|
45
|
+
"@aws-sdk/client-dynamodb": "^3.980.0",
|
|
46
|
+
"@aws-sdk/client-sqs": "^3.980.0",
|
|
47
|
+
"@aws-sdk/client-s3": "^3.980.0",
|
|
48
|
+
"@aws-sdk/client-sns": "^3.980.0",
|
|
49
|
+
"@aws-sdk/client-ssm": "^3.980.0",
|
|
50
|
+
"@aws-sdk/s3-request-presigner": "^3.980.0",
|
|
51
|
+
"@aws-sdk/util-dynamodb": "^3.980.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@aws-sdk/util-stream-node": "^3.370.0",
|