@node-in-layers/aws 1.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/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # AWS - A Node In Layers Package for AWS services
2
+
3
+ This package has a number of apps that assist with using AWS.
4
+
5
+ ## How to Install
6
+
7
+ ```
8
+ npm install @node-in-layers/aws
9
+ ```
10
+
11
+ ## Config
12
+
13
+ The config app provides a globals file, that will take your configuration object, see if there are parameter store and secrets manager objects in it. If there are, it will rearch out to each of those services to find and the replace them within the config.
14
+
15
+ ### How To Use
16
+
17
+ Within the apps of your system's configuration:
18
+
19
+ ```javascript
20
+ import { CoreNamespace } from '@node-in-layers/core/index.js'
21
+
22
+ const core = {
23
+ apps: await Promise.all([
24
+ // Adds support for aws config files.
25
+ import('@node-in-layers/aws/config/index.js'),
26
+ ]),
27
+ layerOrder: ['services', 'features', 'express'],
28
+ logLevel: 'debug',
29
+ logFormat: 'full',
30
+ }
31
+
32
+ export default () => ({
33
+ systemName: 'my-example-system',
34
+ environment: 'dev',
35
+ [CoreNamespace.root]: core,
36
+ })
37
+ ```
38
+
39
+ ### Example Config
40
+
41
+ ```json
42
+ {
43
+ "myApp": {
44
+ "myClient": {
45
+ "url": "https://some-url",
46
+ "key": {
47
+ "type": "secretsManager",
48
+ "key": "/path/with-in/secrets-manager"
49
+ }
50
+ },
51
+ "aDynamicAwsPath": {
52
+ "type": "parameterStore",
53
+ "key": "/path/with-in/parameter-store"
54
+ }
55
+ }
56
+ }
57
+ ```
58
+
59
+ Gets turned into...
60
+
61
+ ```json
62
+ {
63
+ "myApp": {
64
+ "myClient": {
65
+ "url": "https://some-url",
66
+ "key": "the-value-from-secrets-manager"
67
+ },
68
+ "aDynamicAwsPath": "the-value-from-parameter-store"
69
+ }
70
+ }
71
+ ```
72
+
73
+ search parameter store and secrets
package/aws/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { AwsNamespace } from '../types.js';
2
+ declare const name = AwsNamespace.root;
3
+ export * as services from './services.js';
4
+ export { name };
package/aws/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { AwsNamespace } from '../types.js';
2
+ const name = AwsNamespace.root;
3
+ export * as services from './services.js';
4
+ export { name };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/aws/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAA;AAE9B,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { Aws3Config } from '../types.js';
2
+ declare const createAws3Client: (config: Aws3Config) => any;
3
+ declare const create: ({ config }: {
4
+ config: any;
5
+ }) => {
6
+ aws3: any;
7
+ };
8
+ export { create, createAws3Client };
@@ -0,0 +1,55 @@
1
+ import https from 'node:https';
2
+ import merge from 'lodash/merge.js';
3
+ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
4
+ import * as ecs from '@aws-sdk/client-ecs';
5
+ import * as s3 from '@aws-sdk/client-s3';
6
+ import * as dynamo from '@aws-sdk/client-dynamodb';
7
+ import * as libDynamo from '@aws-sdk/lib-dynamodb';
8
+ import * as ssm from '@aws-sdk/client-ssm';
9
+ import * as secretsManager from '@aws-sdk/client-secrets-manager';
10
+ import { memoizeValueSync } from '@node-in-layers/core/utils.js';
11
+ import { AwsNamespace, AwsService } from '../types.js';
12
+ const _awsServiceToBuilder = {
13
+ [AwsService.s3]: awsConfig => ({
14
+ ecs: Object.assign({ s3Client: new s3.S3Client(awsConfig) }, ssm),
15
+ }),
16
+ [AwsService.ecs]: awsConfig => ({
17
+ ecs: Object.assign({ ecsClient: new ecs.ECSClient(awsConfig) }, ssm),
18
+ }),
19
+ [AwsService.ssm]: awsConfig => ({
20
+ ssm: Object.assign({ ssmClient: new ssm.SSMClient(awsConfig) }, ssm),
21
+ }),
22
+ [AwsService.dynamoDb]: awsConfig => ({
23
+ dynamo: Object.assign(Object.assign({ dynamoDbClient: new DynamoDBClient(awsConfig) }, dynamo), libDynamo),
24
+ }),
25
+ [AwsService.secretsManager]: awsConfig => ({
26
+ secretsManager: Object.assign({ secretsManagerClient: new secretsManager.SecretsManagerClient(awsConfig) }, secretsManager),
27
+ }),
28
+ };
29
+ const createAws3Client = memoizeValueSync((config) => {
30
+ var _a, _b;
31
+ const sslAgent = ((_a = config[AwsNamespace.root]) === null || _a === void 0 ? void 0 : _a.httpsAgent) ||
32
+ new https.Agent({
33
+ keepAlive: true,
34
+ maxSockets: 50,
35
+ });
36
+ const awsConfig = {
37
+ httpOptions: {
38
+ agent: sslAgent,
39
+ },
40
+ };
41
+ const services = ((_b = config[AwsNamespace.root]) === null || _b === void 0 ? void 0 : _b.services) || Object.values(AwsService);
42
+ const aws3 = services.reduce((acc, service) => {
43
+ const obj = _awsServiceToBuilder[service](awsConfig);
44
+ return merge(acc, obj);
45
+ }, {});
46
+ return aws3;
47
+ });
48
+ const create = ({ config }) => {
49
+ const aws3 = createAws3Client(config);
50
+ return {
51
+ aws3,
52
+ };
53
+ };
54
+ export { create, createAws3Client };
55
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/aws/services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAA;AAC9B,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAA;AAClD,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAA;AAClD,OAAO,KAAK,GA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C,0CAAE,UAAU;QACrC,IAAI,KAAK,CAAC,KAAK,CAAC;YACd,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,EAAE;SACf,CAAC,CAAA;IACJ,MAAM,SAAS,GAAG;QAChB,WAAW,EAAE;YACX,KAAK,EAAE,QAAQ;SAChB;KACF,CAAA;IAED,MAAM,QAAQ,GACZ,CAAA,MAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,0CAAE,QAAQ,KAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAElE,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC5C,MAAM,GAAG,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,CAAA;QACpD,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IACxB,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,IAAY,CAAA;AACrB,CAAC,CAAC,CAAA;AAEF,MAAM,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;IAC5B,MAAM,IAAI,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACrC,OAAO;QACL,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAA"}
@@ -0,0 +1,150 @@
1
+ import { Config, FeaturesContext } from '@node-in-layers/core/index.js';
2
+ import { AwsConfigServicesLayer, AwsConfigFeaturesLayer } from './types.js';
3
+ declare const create: (context: FeaturesContext<Config, AwsConfigServicesLayer, AwsConfigFeaturesLayer>) => {
4
+ replaceAwsConfigObjects: <TConfig extends Readonly<{
5
+ systemName: string;
6
+ environment: string;
7
+ "@node-in-layers/core": {
8
+ logLevel: import("@node-in-layers/core/types.js").LogLevelNames;
9
+ logFormat: import("@node-in-layers/core/types.js").LogFormat;
10
+ layerOrder: readonly import("@node-in-layers/core/types.js").LayerDescription[];
11
+ apps: readonly Readonly<{
12
+ name: string;
13
+ services?: Readonly<{
14
+ create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
15
+ }> | undefined;
16
+ features?: Readonly<{
17
+ create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
18
+ }> | undefined;
19
+ globals?: Readonly<{
20
+ create: (context: Readonly<{
21
+ node: Readonly<{
22
+ fs: Readonly<{
23
+ mkdirSync: (path: string, options?: {
24
+ recursive?: boolean | undefined;
25
+ } | undefined) => void;
26
+ readFileSync: (path: string, encoding?: any) => string;
27
+ writeFileSync: (path: string, data: any) => void;
28
+ existsSync: (path: string) => boolean;
29
+ lstatSync: (path: string) => {
30
+ isFile: () => boolean;
31
+ isDirectory: () => boolean;
32
+ isBlockDevice: () => boolean;
33
+ isCharacterDevice: () => boolean;
34
+ isSymbolicLink: () => boolean;
35
+ isFIFO: () => boolean;
36
+ isSocket: () => boolean;
37
+ };
38
+ }>;
39
+ }>;
40
+ config: Readonly<any>;
41
+ log: Readonly<{
42
+ getLogger: (name: string) => Readonly<{
43
+ trace: (...msg: any[]) => void;
44
+ debug: (...msg: any[]) => void;
45
+ info: (...msg: any[]) => void;
46
+ warn: (...msg: any[]) => void;
47
+ error: (...msg: any[]) => void;
48
+ }>;
49
+ }>;
50
+ constants: {
51
+ environment: string;
52
+ workingDirectory: string;
53
+ };
54
+ }>) => Promise<any>;
55
+ }> | undefined;
56
+ models?: Record<string, Readonly<{
57
+ create: <T extends Readonly<{
58
+ [s: string]: any;
59
+ }>, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(modelProps: Readonly<{
60
+ Model: import("functional-models/types.js").ModelFactory<object, object>;
61
+ fetcher: import("functional-models/types.js").ModelInstanceFetcher<object, object>;
62
+ getModel: <T_1 extends Readonly<{
63
+ [s: string]: any;
64
+ }>>(namespace: string, modelName: string) => () => import("functional-models/types.js").ModelType<T_1, object, object>;
65
+ }>) => import("functional-models/types.js").ModelType<T, TModelExtensions, TModelInstanceExtensions>;
66
+ }>> | undefined;
67
+ }>[];
68
+ modelFactory?: string | undefined;
69
+ modelCruds?: boolean | undefined;
70
+ customModelFactory?: {
71
+ [x: string]: {
72
+ [x: string]: string | [string, any[]];
73
+ };
74
+ } | undefined;
75
+ };
76
+ }> = Readonly<{
77
+ systemName: string;
78
+ environment: string;
79
+ "@node-in-layers/core": {
80
+ logLevel: import("@node-in-layers/core/types.js").LogLevelNames;
81
+ logFormat: import("@node-in-layers/core/types.js").LogFormat;
82
+ layerOrder: readonly import("@node-in-layers/core/types.js").LayerDescription[];
83
+ apps: readonly Readonly<{
84
+ name: string;
85
+ services?: Readonly<{
86
+ create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
87
+ }> | undefined;
88
+ features?: Readonly<{
89
+ create: (context: any) => import("@node-in-layers/core/types.js").MaybePromise<object>;
90
+ }> | undefined;
91
+ globals?: Readonly<{
92
+ create: (context: Readonly<{
93
+ node: Readonly<{
94
+ fs: Readonly<{
95
+ mkdirSync: (path: string, options?: {
96
+ recursive?: boolean | undefined;
97
+ } | undefined) => void;
98
+ readFileSync: (path: string, encoding?: any) => string;
99
+ writeFileSync: (path: string, data: any) => void;
100
+ existsSync: (path: string) => boolean;
101
+ lstatSync: (path: string) => {
102
+ isFile: () => boolean;
103
+ isDirectory: () => boolean;
104
+ isBlockDevice: () => boolean;
105
+ isCharacterDevice: () => boolean;
106
+ isSymbolicLink: () => boolean;
107
+ isFIFO: () => boolean;
108
+ isSocket: () => boolean;
109
+ };
110
+ }>;
111
+ }>;
112
+ config: Readonly<any>;
113
+ log: Readonly<{
114
+ getLogger: (name: string) => Readonly<{
115
+ trace: (...msg: any[]) => void;
116
+ debug: (...msg: any[]) => void;
117
+ info: (...msg: any[]) => void;
118
+ warn: (...msg: any[]) => void;
119
+ error: (...msg: any[]) => void;
120
+ }>;
121
+ }>;
122
+ constants: {
123
+ environment: string;
124
+ workingDirectory: string;
125
+ };
126
+ }>) => Promise<any>;
127
+ }> | undefined;
128
+ models?: Record<string, Readonly<{
129
+ create: <T extends Readonly<{
130
+ [s: string]: any;
131
+ }>, TModelExtensions extends object = object, TModelInstanceExtensions extends object = object>(modelProps: Readonly<{
132
+ Model: import("functional-models/types.js").ModelFactory<object, object>;
133
+ fetcher: import("functional-models/types.js").ModelInstanceFetcher<object, object>;
134
+ getModel: <T_1 extends Readonly<{
135
+ [s: string]: any;
136
+ }>>(namespace: string, modelName: string) => () => import("functional-models/types.js").ModelType<T_1, object, object>;
137
+ }>) => import("functional-models/types.js").ModelType<T, TModelExtensions, TModelInstanceExtensions>;
138
+ }>> | undefined;
139
+ }>[];
140
+ modelFactory?: string | undefined;
141
+ modelCruds?: boolean | undefined;
142
+ customModelFactory?: {
143
+ [x: string]: {
144
+ [x: string]: string | [string, any[]];
145
+ };
146
+ } | undefined;
147
+ };
148
+ }>>(rawConfig: TConfig) => Promise<TConfig>;
149
+ };
150
+ export { create };
@@ -0,0 +1,40 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import isEmpty from 'lodash/isEmpty.js';
11
+ import { AwsNamespace } from '../types.js';
12
+ import { findSecretsManagerEntries, findParameterStoreEntries, applyParameterStore, applySecrets, } from './lib.js';
13
+ const create = (
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ context) => {
16
+ const replaceAwsConfigObjects = (rawConfig) => {
17
+ return Promise.resolve().then(() => __awaiter(void 0, void 0, void 0, function* () {
18
+ const secretsNeeded = findSecretsManagerEntries(rawConfig);
19
+ const secretsApplied = yield (isEmpty(secretsNeeded) === false
20
+ ? (() => __awaiter(void 0, void 0, void 0, function* () {
21
+ const secrets = yield context.services[AwsNamespace.config].readSecretsInSecretsManager(Object.values(secretsNeeded).map(x => x.key));
22
+ return applySecrets(rawConfig, secretsNeeded, secrets);
23
+ }))()
24
+ : rawConfig);
25
+ const parameterStoreNeeded = findParameterStoreEntries(rawConfig);
26
+ const parametersApplied = yield (isEmpty(parameterStoreNeeded) === false
27
+ ? (() => __awaiter(void 0, void 0, void 0, function* () {
28
+ const parameters = yield context.services[AwsNamespace.config].readParameters(Object.values(parameterStoreNeeded).map(x => x.key));
29
+ return applyParameterStore(secretsApplied, parameterStoreNeeded, parameters);
30
+ }))()
31
+ : rawConfig);
32
+ return parametersApplied;
33
+ }));
34
+ };
35
+ return {
36
+ replaceAwsConfigObjects,
37
+ };
38
+ };
39
+ export { create };
40
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features.js","sourceRoot":"","sources":["../../src/config/features.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,OAAO,MAAM,mBAAmB,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,GACb,MAAM,UAAU,CAAA;AAEjB,MAAM,MAAM,GAAG;AACb,6DAA6D;AAC7D,OAIC,EACD,EAAE;IACF,MAAM,uBAAuB,GAAG,CAC9B,SAAkB,EACA,EAAE;QACpB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAS,EAAE;YACvC,MAAM,aAAa,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAA;YAC1D,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,KAAK;gBAC5D,CAAC,CAAC,CAAC,GAAS,EAAE;oBACV,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,QAAQ,CACpC,YAAY,CAAC,MAAM,CACpB,CAAC,2BAA2B,CAC3B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAC7C,CAAA;oBACD,OAAO,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,CAAY,CAAA;gBACnE,CAAC,CAAA,CAAC,EAAE;gBACN,CAAC,CAAC,SAAS,CAAC,CAAA;YAEd,MAAM,oBAAoB,GAAG,yBAAyB,CAAC,SAAS,CAAC,CAAA;YACjE,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,KAAK;gBACtE,CAAC,CAAC,CAAC,GAAS,EAAE;oBACV,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CACvC,YAAY,CAAC,MAAM,CACpB,CAAC,cAAc,CACd,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CACpD,CAAA;oBACD,OAAO,mBAAmB,CACxB,cAAc,EACd,oBAAoB,EACpB,UAAU,CACA,CAAA;gBACd,CAAC,CAAA,CAAC,EAAE;gBACN,CAAC,CAAC,SAAS,CAAC,CAAA;YAEd,OAAO,iBAA4B,CAAA;QACrC,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,uBAAuB;KACxB,CAAA;AACH,CAAC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Replaces objects within the config
3
+ */
4
+ declare const create: (context: any) => Promise<{
5
+ config: any;
6
+ }>;
7
+ export { create };
@@ -0,0 +1,27 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as rootServices from '../aws/services.js';
11
+ import { AwsNamespace } from '../types.js';
12
+ import * as services from './services.js';
13
+ import * as features from './features.js';
14
+ /**
15
+ * Replaces objects within the config
16
+ */
17
+ const create = (context) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const rServices = rootServices.create(context);
19
+ const sInstance = services.create(Object.assign(Object.assign({}, context), { [AwsNamespace.root]: rServices }));
20
+ const f = features.create(Object.assign(Object.assign({}, context), { [AwsNamespace.config]: sInstance }));
21
+ const newConfig = yield f.replaceAwsConfigObjects(context.config);
22
+ return {
23
+ config: newConfig,
24
+ };
25
+ });
26
+ export { create };
27
+ //# sourceMappingURL=globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/config/globals.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,GAAG,CAAM,OAAO,EAAC,EAAE;IAC7B,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,iCAC5B,OAAO,KACV,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,SAAS,IAC9B,CAAA;IACF,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,iCACpB,OAAO,KACV,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS,IAChC,CAAA;IAEF,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEjE,OAAO;QACL,MAAM,EAAE,SAAS;KAClB,CAAA;AACH,CAAC,CAAA,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * as globals from './globals.js';
2
+ declare const name = "@node-in-layers/aws-config";
3
+ export { name };
@@ -0,0 +1,4 @@
1
+ export * as globals from './globals.js';
2
+ const name = '@node-in-layers/aws-config';
3
+ export { name };
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC,MAAM,IAAI,GAAG,4BAA4B,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,30 @@
1
+ import { AwsEntryType } from './types.js';
2
+ /**
3
+ * Finds the secrets manager entries in the config file.
4
+ */
5
+ declare const findSecretsManagerEntries: (rawConfig: object) => Readonly<Record<string, Readonly<{
6
+ type: AwsEntryType.secretsManager;
7
+ key: string;
8
+ }>>>;
9
+ /**
10
+ * Finds parameter store entries in the configuration file
11
+ */
12
+ declare const findParameterStoreEntries: (rawConfig: object) => Readonly<Record<string, Readonly<{
13
+ type: AwsEntryType.parameterStore;
14
+ key: string;
15
+ }>>>;
16
+ /**
17
+ * Replaces secrets manager entries with their value.
18
+ */
19
+ declare const applySecrets: (rawConfig: object, toReplace: Readonly<Record<string, Readonly<{
20
+ type: AwsEntryType.secretsManager;
21
+ key: string;
22
+ }>>>, entries: object) => object;
23
+ /**
24
+ * Replaces parameter store entries with their value.
25
+ */
26
+ declare const applyParameterStore: (rawConfig: object, toReplace: Readonly<Record<string, Readonly<{
27
+ type: AwsEntryType.parameterStore;
28
+ key: string;
29
+ }>>>, entries: object) => object;
30
+ export { applyParameterStore, applySecrets, findParameterStoreEntries, findSecretsManagerEntries, };
package/config/lib.js ADDED
@@ -0,0 +1,66 @@
1
+ import get from 'lodash/get.js';
2
+ import merge from 'lodash/merge.js';
3
+ import set from 'lodash/set.js';
4
+ import isPlainObject from 'lodash/isPlainObject.js';
5
+ import { AwsEntryKey, AwsEntryType, } from './types.js';
6
+ const _findObjects = (path, obj, isMatch) => {
7
+ if (isPlainObject(obj)) {
8
+ const match = isMatch(obj);
9
+ if (match) {
10
+ if (!path) {
11
+ throw new Error(`Cannot match base object`);
12
+ }
13
+ return [path];
14
+ }
15
+ return Object.entries(obj).reduce((acc, [key, value]) => {
16
+ const fullPath = path ? `${path}.${key}` : key;
17
+ return acc.concat(_findObjects(fullPath, value, isMatch));
18
+ }, []);
19
+ }
20
+ return [];
21
+ };
22
+ const findNestedObjects = (obj, isMatch) => {
23
+ return _findObjects(undefined, obj, isMatch);
24
+ };
25
+ const _findAwsEntries = (type) => (rawConfig) => {
26
+ return findNestedObjects(rawConfig, (obj) => {
27
+ return AwsEntryKey in obj && obj[AwsEntryKey] === type;
28
+ }).reduce((acc, path) => {
29
+ return merge(acc, {
30
+ [path]: get(rawConfig, path),
31
+ });
32
+ }, {});
33
+ };
34
+ /**
35
+ * Finds the secrets manager entries in the config file.
36
+ */
37
+ const findSecretsManagerEntries = _findAwsEntries(AwsEntryType.secretsManager);
38
+ /**
39
+ * Finds parameter store entries in the configuration file
40
+ */
41
+ const findParameterStoreEntries = _findAwsEntries(AwsEntryType.parameterStore);
42
+ /**
43
+ * Finds an entry within the configuration file that needs to be replaced.
44
+ * @param rawConfig
45
+ * @param toReplace
46
+ * @param entries
47
+ */
48
+ const applyAwsEntry = (rawConfig, toReplace, entries) => {
49
+ return Object.entries(toReplace).reduce((acc, [path, partial]) => {
50
+ const secret = entries[partial.key];
51
+ if (!secret) {
52
+ throw new Error(`Must include secret for ${partial.key}`);
53
+ }
54
+ return set(acc, path, secret);
55
+ }, rawConfig);
56
+ };
57
+ /**
58
+ * Replaces secrets manager entries with their value.
59
+ */
60
+ const applySecrets = (applyAwsEntry);
61
+ /**
62
+ * Replaces parameter store entries with their value.
63
+ */
64
+ const applyParameterStore = (applyAwsEntry);
65
+ export { applyParameterStore, applySecrets, findParameterStoreEntries, findSecretsManagerEntries, };
66
+ //# sourceMappingURL=lib.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/config/lib.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,GAAG,MAAM,eAAe,CAAA;AAC/B,OAAO,aAAa,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAEL,WAAW,EACX,YAAY,GAGb,MAAM,YAAY,CAAA;AAEnB,MAAM,YAAY,GAAG,CACnB,IAAwB,EACxB,GAAQ,EACR,OAAiC,EACvB,EAAE;IACZ,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAA;QAC1B,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAA;QACf,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;YAC9C,OAAO,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CA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AAC,2BAA2B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QAC3D,CAAC;QACD,OAAO,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC,EAAE,SAAS,CAAC,CAAA;AACf,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,YAAY,GAAG,CAAA,aAGpB,CAAA,CAAA;AAED;;GAEG;AACH,MAAM,mBAAmB,GAAG,CAAA,aAG3B,CAAA,CAAA;AAED,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,GAC1B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { ServicesContext } from '@node-in-layers/core/index.js';
2
+ import { AwsConfigServices } from './types.js';
3
+ declare const create: (context: ServicesContext) => AwsConfigServices;
4
+ export { create };
@@ -0,0 +1,49 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import merge from 'lodash/merge.js';
11
+ import { asyncMap } from 'modern-async';
12
+ import { AwsNamespace } from '../types.js';
13
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
+ const create = (context) => {
15
+ const readSecretsInSecretsManager = (keys) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const secretsManager = context[AwsNamespace.root].aws3.secretsManager.secretsManagerClient;
17
+ const mapped = yield asyncMap(keys, (secretId) => __awaiter(void 0, void 0, void 0, function* () {
18
+ const command = new context[AwsNamespace.root].aws3.secretsManager.GetSecretValueCommand({
19
+ SecretId: secretId,
20
+ });
21
+ const result = yield secretsManager.send(command);
22
+ return [secretId, result.SecretString];
23
+ }), 1);
24
+ return mapped.reduce((acc, [key, secret]) => {
25
+ return merge(acc, { [key]: secret });
26
+ }, {});
27
+ });
28
+ const readParameters = (keys) => __awaiter(void 0, void 0, void 0, function* () {
29
+ return Promise.resolve().then(() => __awaiter(void 0, void 0, void 0, function* () {
30
+ const ssm = context[AwsNamespace.root].aws3.ssm.ssmClient;
31
+ const mapped = yield asyncMap(keys, (key) => __awaiter(void 0, void 0, void 0, function* () {
32
+ const command = new context[AwsNamespace.root].aws3.ssm.GetParameterCommand({
33
+ Name: key,
34
+ });
35
+ const result = yield ssm.send(command);
36
+ return [key, result.Parameter.Value];
37
+ }), 1);
38
+ return mapped.reduce((acc, [key, secret]) => {
39
+ return merge(acc, { [key]: secret });
40
+ }, {});
41
+ }));
42
+ });
43
+ return {
44
+ readSecretsInSecretsManager,
45
+ readParameters,
46
+ };
47
+ };
48
+ export { create };
49
+ //# sourceMappingURL=services.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/config/services.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,iBAAiB,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAG1C,6DAA6D;AAC7D,MAAM,MAAM,GAAG,CAAC,OAAwB,EAAqB,EAAE;IAC7D,MAAM,2BAA2B,GAAG,CAAO,IAAc,EAAE,EAAE;QAC3D,MAAM,cAAc,GAClB,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAA;QACrE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAC3B,IAAI,EACJ,CAAM,QAAQ,EAAC,EAAE;YACf,MAAM,OAAO,GAAG,IAAI,OAAO,CACzB,YAAY,CAAC,IAAI,CACl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EAAE,EAAE;gBAC1C,OAAO,KAAK,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;YACtC,CAAC,EAAE,EAAE,CAAC,CAAA;QACR,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAA,CAAA;IAED,OAAO;QACL,2BAA2B;QAC3B,cAAc;KACf,CAAA;AACH,CAAC,CAAA;AACD,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,42 @@
1
+ type AwsConfigServices = Readonly<object>;
2
+ type AwsConfigServicesLayer = Readonly<{
3
+ 'aws-config/aws-config': AwsConfigServices;
4
+ }>;
5
+ type AwsConfigFeatures = Readonly<object>;
6
+ type AwsConfigFeaturesLayer = Readonly<{
7
+ 'aws-config/aws-config': AwsConfigFeatures;
8
+ }>;
9
+ type AwsConfigNamespace = Readonly<{
10
+ root: '@node-in-layers/aws-config';
11
+ }>;
12
+ /**
13
+ * The key that defines an aws entry
14
+ */
15
+ declare const AwsEntryKey = "type";
16
+ /**
17
+ * The type of supported aws entries in a config.
18
+ */
19
+ declare enum AwsEntryType {
20
+ secretsManager = "secretsManager",
21
+ parameterStore = "parameterStore"
22
+ }
23
+ /**
24
+ * An AWS entry that has not been replaced yet.
25
+ */
26
+ type PartialAwsEntry<T extends AwsEntryType> = Readonly<{
27
+ type: T;
28
+ key: string;
29
+ }>;
30
+ /**
31
+ * An object that holds multiple Aws entries to replace.
32
+ */
33
+ type AwsEntriesToReplace<T extends AwsEntryType> = Readonly<Record<string, PartialAwsEntry<T>>>;
34
+ /**
35
+ * All the secrets manager entries to replace
36
+ */
37
+ type SecretsToReplace = AwsEntriesToReplace<AwsEntryType.secretsManager>;
38
+ /**
39
+ * All the parameter store entries to replace
40
+ */
41
+ type ParameterStoreToReplace = AwsEntriesToReplace<AwsEntryType.parameterStore>;
42
+ export { AwsConfigServices, AwsConfigServicesLayer, AwsConfigFeatures, AwsConfigFeaturesLayer, AwsConfigNamespace, AwsEntriesToReplace, AwsEntryKey, AwsEntryType, ParameterStoreToReplace, SecretsToReplace, };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The key that defines an aws entry
3
+ */
4
+ const AwsEntryKey = 'type';
5
+ /**
6
+ * The type of supported aws entries in a config.
7
+ */
8
+ var AwsEntryType;
9
+ (function (AwsEntryType) {
10
+ AwsEntryType["secretsManager"] = "secretsManager";
11
+ AwsEntryType["parameterStore"] = "parameterStore";
12
+ })(AwsEntryType || (AwsEntryType = {}));
13
+ export { AwsEntryKey, AwsEntryType, };
14
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,MAAM,WAAW,GAAG,MAAM,CAAA;AAE1B;;GAEG;AACH,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;AACnC,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AA2BD,OAAO,EAOL,WAAW,EACX,YAAY,GAGb,CAAA"}
package/package.json ADDED
@@ -0,0 +1,102 @@
1
+ {
2
+ "name": "@node-in-layers/aws",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "A Node In Layers Package for handling AWS.",
6
+ "main": "index.js",
7
+ "scripts": {
8
+ "build": "rm -Rf ./dist && tsc -p ./tsconfig.json && cp package.json ./dist && cp README.md ./dist",
9
+ "build:watch": "nodemon -e '*' --watch ./src --exec \"npm run build || exit 1\"",
10
+ "commit": "cz",
11
+ "dist": "npm run build && cd dist && npm publish",
12
+ "eslint": "eslint .",
13
+ "prettier": "prettier --write .",
14
+ "test1": "export TS_NODE_PROJECT='./tsconfig.test.json' && mocha -r tsx ./test/src/*.test.ts ./test/src/**/*.test.ts ./test/src/**/**/*.test.ts",
15
+ "test2": "export TS_NODE_PROJECT='./tsconfig.test.json' && mocha -r ts-node/register test/**/*.test.ts",
16
+ "test": "export TS_NODE_PROJECT='./tsconfig.test.json' && mocha -r tsx test/**/**/*.test.ts test/**/*.test.ts",
17
+ "test:coverage": "c8 --all --reporter cobertura --reporter text --reporter lcov --reporter html npm run test",
18
+ "test:features": "./node_modules/.bin/cucumber-js -p default"
19
+ },
20
+ "config": {
21
+ "commitizen": {
22
+ "path": "./node_modules/cz-conventional-changelog"
23
+ }
24
+ },
25
+ "nyc": {
26
+ "check-coverage": true,
27
+ "all": true,
28
+ "include": [
29
+ "src/**/**/*.ts",
30
+ "src/**/*.ts"
31
+ ],
32
+ "exclude": [
33
+ "src/_tests_/**/*.*",
34
+ "node_modules",
35
+ ".nyc_output",
36
+ "coverage",
37
+ ".git",
38
+ ".github",
39
+ "features"
40
+ ],
41
+ "reporter": [
42
+ "html",
43
+ "lcov",
44
+ "text",
45
+ "text-summary"
46
+ ],
47
+ "report-dir": "coverage"
48
+ },
49
+ "author": "Mike Cornwell",
50
+ "license": "GPLV3",
51
+ "devDependencies": {
52
+ "@cucumber/cucumber": "11.0.1",
53
+ "@eslint/compat": "^1.2.0",
54
+ "@eslint/eslintrc": "^3.1.0",
55
+ "@eslint/js": "^9.12.0",
56
+ "@types/chai-as-promised": "^8.0.1",
57
+ "@types/json-stringify-safe": "^5.0.3",
58
+ "@types/lodash": "^4.17.13",
59
+ "@types/mocha": "^9.1.1",
60
+ "@types/node": "^22.9.0",
61
+ "@types/proxyquire": "^1.3.31",
62
+ "@types/sinon": "^17.0.3",
63
+ "@typescript-eslint/eslint-plugin": "8.13.0",
64
+ "@typescript-eslint/parser": "8.13.0",
65
+ "argparse": "^2.0.1",
66
+ "chai": "^4.2.0",
67
+ "chai-as-promised": "^7.1.1",
68
+ "cz-conventional-changelog": "^3.3.0",
69
+ "eslint": "9.14.0",
70
+ "eslint-config-prettier": "^9.1.0",
71
+ "eslint-import-resolver-typescript": "^3.6.3",
72
+ "eslint-plugin-functional": "~7.1.0",
73
+ "eslint-plugin-import": "^2.31.0",
74
+ "esprima": "^4.0.1",
75
+ "globals": "^15.12.0",
76
+ "handlebars": "^4.7.8",
77
+ "js-yaml": "^4.1.0",
78
+ "mocha": "^11.0.1",
79
+ "nodemon": "^3.1.7",
80
+ "prettier": "^3.3.3",
81
+ "proxyquire": "^2.1.3",
82
+ "sinon": "^19.0.2",
83
+ "sinon-chai": "^3.5.0",
84
+ "source-map-support": "^0.5.21",
85
+ "ts-mocha": "^11.1.0",
86
+ "ts-node": "^10.9.2",
87
+ "tsx": "^4.19.3",
88
+ "typescript": "5.3.3"
89
+ },
90
+ "dependencies": {
91
+ "@aws-sdk/client-dynamodb": "^3.758.0",
92
+ "@aws-sdk/client-ecs": "^3.758.0",
93
+ "@aws-sdk/client-s3": "^3.758.0",
94
+ "@aws-sdk/client-secrets-manager": "^3.758.0",
95
+ "@aws-sdk/client-ssm": "^3.759.0",
96
+ "@aws-sdk/lib-dynamodb": "^3.758.0",
97
+ "@node-in-layers/core": "^1.1.6",
98
+ "c8": "^10.1.3",
99
+ "lodash": "^4.17.21",
100
+ "modern-async": "^2.0.4"
101
+ }
102
+ }
package/types.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { Config } from '@node-in-layers/core';
2
+ type Aws3 = Readonly<{
3
+ ecs: Record<string, any> & {
4
+ ecsClient: any;
5
+ };
6
+ s3: Record<string, any> & {
7
+ s3Client: any;
8
+ };
9
+ dynamo: Record<string, any> & {
10
+ dynamoDbClient: any;
11
+ };
12
+ ssm: Record<string, any> & {
13
+ ssmClient: any;
14
+ GetParameterCommand: any;
15
+ };
16
+ secretsManager: Record<string, any> & {
17
+ secretsManagerClient: any;
18
+ GetSecretValueCommand: any;
19
+ };
20
+ }>;
21
+ declare enum AwsNamespace {
22
+ root = "@node-in-layers/aws",
23
+ config = "@node-in-layers/aws/config"
24
+ }
25
+ declare enum AwsService {
26
+ s3 = 0,
27
+ ssm = 1,
28
+ secretsManager = 2,
29
+ dynamoDb = 3,
30
+ ecs = 4
31
+ }
32
+ type Aws3Config = Config & Partial<Readonly<{
33
+ [AwsNamespace.root]: {
34
+ services?: readonly AwsService[];
35
+ httpsAgent?: any;
36
+ };
37
+ }>>;
38
+ export { AwsNamespace, Aws3Config, Aws3, AwsService };
package/types.js ADDED
@@ -0,0 +1,15 @@
1
+ var AwsNamespace;
2
+ (function (AwsNamespace) {
3
+ AwsNamespace["root"] = "@node-in-layers/aws";
4
+ AwsNamespace["config"] = "@node-in-layers/aws/config";
5
+ })(AwsNamespace || (AwsNamespace = {}));
6
+ var AwsService;
7
+ (function (AwsService) {
8
+ AwsService[AwsService["s3"] = 0] = "s3";
9
+ AwsService[AwsService["ssm"] = 1] = "ssm";
10
+ AwsService[AwsService["secretsManager"] = 2] = "secretsManager";
11
+ AwsService[AwsService["dynamoDb"] = 3] = "dynamoDb";
12
+ AwsService[AwsService["ecs"] = 4] = "ecs";
13
+ })(AwsService || (AwsService = {}));
14
+ export { AwsNamespace, AwsService };
15
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAsBA,IAAK,YAGJ;AAHD,WAAK,YAAY;IACf,4CAA4B,CAAA;IAC5B,qDAAqC,CAAA;AACvC,CAAC,EAHI,YAAY,KAAZ,YAAY,QAGhB;AAED,IAAK,UAMJ;AAND,WAAK,UAAU;IACb,uCAAE,CAAA;IACF,yCAAG,CAAA;IACH,+DAAc,CAAA;IACd,mDAAQ,CAAA;IACR,yCAAG,CAAA;AACL,CAAC,EANI,UAAU,KAAV,UAAU,QAMd;AAYD,OAAO,EAAE,YAAY,EAAoB,UAAU,EAAE,CAAA"}