@dmptool/utils 1.0.34 → 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 CHANGED
@@ -1,12 +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 logger The logger to use for logging.
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`.
15
+ * Should be false when running in a local development environment.
9
16
  * @returns The value of the variable, or undefined if the variable could not be found.
10
17
  * @throws
11
18
  */
12
- export declare const getSSMParameter: (logger: Logger, key: string, env?: EnvironmentEnum) => Promise<string | undefined>;
19
+ export declare const getSSMParameter: (connectionParams: SsmConnectionParams, key: string, env?: EnvironmentEnum, endpoint?: string) => Promise<string | undefined>;
package/dist/ssm.js CHANGED
@@ -6,19 +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 logger The logger to use for logging.
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
+ * Should be false when running in a local development environment.
12
13
  * @returns The value of the variable, or undefined if the variable could not be found.
13
14
  * @throws
14
15
  */
15
- const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV) => {
16
+ const getSSMParameter = async (connectionParams, key, env = general_1.EnvironmentEnum.DEV, endpoint) => {
16
17
  var _a;
17
- if (logger && key && key.trim() !== '') {
18
- // Create an SSM client
19
- const client = new client_ssm_1.SSMClient();
18
+ if (connectionParams.logger && key && key.trim() !== '') {
19
+ // Create an SSM client (use the endpoint if we are not using TLS - local dev)
20
+ const client = connectionParams.useTLS
21
+ ? new client_ssm_1.SSMClient()
22
+ : new client_ssm_1.SSMClient(connectionParams);
20
23
  const keyPrefix = `/uc3/dmp/tool/${env.toLowerCase()}/`;
21
- logger.debug(`Fetching parameter ${keyPrefix}${key}`);
24
+ connectionParams.logger.debug(`Fetching parameter ${keyPrefix}${key}`);
22
25
  try {
23
26
  const command = new client_ssm_1.GetParameterCommand({
24
27
  Name: `${keyPrefix}${key}`,
@@ -28,10 +31,10 @@ const getSSMParameter = async (logger, key, env = general_1.EnvironmentEnum.DEV)
28
31
  if (!(0, general_1.isNullOrUndefined)(response) && !(0, general_1.isNullOrUndefined)(response.Parameter)) {
29
32
  return (_a = response.Parameter) === null || _a === void 0 ? void 0 : _a.Value;
30
33
  }
31
- logger.warn(`Parameter ${keyPrefix}${key} not found.`);
34
+ connectionParams.logger.warn(`Parameter ${keyPrefix}${key} not found.`);
32
35
  }
33
36
  catch (error) {
34
- logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
37
+ connectionParams.logger.fatal(`Error fetching parameter ${keyPrefix}${key}: ${error}`);
35
38
  }
36
39
  }
37
40
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/utils",
3
- "version": "1.0.34",
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.966.0",
45
- "@aws-sdk/client-dynamodb": "^3.966.0",
46
- "@aws-sdk/client-sqs": "^3.968.0",
47
- "@aws-sdk/client-s3": "^3.966.0",
48
- "@aws-sdk/client-sns": "^3.967.0",
49
- "@aws-sdk/client-ssm": "^3.966.0",
50
- "@aws-sdk/s3-request-presigner": "^3.966.0",
51
- "@aws-sdk/util-dynamodb": "^3.966.0"
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",