@flipboxlabs/aws-audit-cdk 1.1.2 → 1.1.3
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/lambda/construct.d.ts +36 -3
- package/dist/lambda/construct.d.ts.map +1 -1
- package/dist/lambda/construct.js +47 -3
- package/dist/lambda/nodejs.function.js +1 -1
- package/package.json +1 -1
- package/dist/lambda/audit-config-layer.d.ts +0 -40
- package/dist/lambda/audit-config-layer.d.ts.map +0 -1
- package/dist/lambda/audit-config-layer.js +0 -50
|
@@ -1,7 +1,40 @@
|
|
|
1
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
2
|
+
import { Construct } from "constructs";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Input configuration for the audit config layer.
|
|
5
|
+
* Contains the apps and resource types that will be available to Lambda handlers.
|
|
6
|
+
*/
|
|
7
|
+
export interface AuditConfigLayerProps {
|
|
8
|
+
/** List of valid application identifiers */
|
|
9
|
+
readonly apps: readonly string[];
|
|
10
|
+
/** List of valid resource type identifiers */
|
|
11
|
+
readonly resourceTypes: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Path where handlers should import the audit config from.
|
|
15
|
+
* This is the standard Lambda layer path for Node.js.
|
|
16
|
+
*/
|
|
17
|
+
export declare const AUDIT_CONFIG_LAYER_PATH = "/opt/nodejs/audit-config.js";
|
|
18
|
+
/**
|
|
19
|
+
* Creates a Lambda layer containing the audit configuration.
|
|
20
|
+
*
|
|
21
|
+
* The layer exports raw `apps` and `resourceTypes` arrays that handlers
|
|
22
|
+
* can use with `defineAuditConfig` from the SDK.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { ConfigLayerConstruct } from "@flipboxlabs/aws-audit-cdk/lambda";
|
|
27
|
+
*
|
|
28
|
+
* const auditLayer = new ConfigLayerConstruct(this, "AuditConfigLayer", {
|
|
29
|
+
* apps: ["Orders", "Inventory"],
|
|
30
|
+
* resourceTypes: ["Order", "Product"],
|
|
31
|
+
* });
|
|
3
32
|
*
|
|
4
|
-
*
|
|
33
|
+
* // Pass auditLayer.layer to constructs that need it
|
|
34
|
+
* ```
|
|
5
35
|
*/
|
|
6
|
-
export
|
|
36
|
+
export declare class ConfigLayerConstruct extends Construct {
|
|
37
|
+
readonly layer: lambda.LayerVersion;
|
|
38
|
+
constructor(scope: Construct, id: string, props: AuditConfigLayerProps);
|
|
39
|
+
}
|
|
7
40
|
//# sourceMappingURL=construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/lambda/construct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../src/lambda/construct.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAClD,SAAgB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC;gBAE/B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;CAuBtE"}
|
package/dist/lambda/construct.js
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
5
|
+
import { Construct } from "constructs";
|
|
1
6
|
/**
|
|
2
|
-
*
|
|
7
|
+
* Path where handlers should import the audit config from.
|
|
8
|
+
* This is the standard Lambda layer path for Node.js.
|
|
9
|
+
*/
|
|
10
|
+
export const AUDIT_CONFIG_LAYER_PATH = "/opt/nodejs/audit-config.js";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a Lambda layer containing the audit configuration.
|
|
13
|
+
*
|
|
14
|
+
* The layer exports raw `apps` and `resourceTypes` arrays that handlers
|
|
15
|
+
* can use with `defineAuditConfig` from the SDK.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { ConfigLayerConstruct } from "@flipboxlabs/aws-audit-cdk/lambda";
|
|
20
|
+
*
|
|
21
|
+
* const auditLayer = new ConfigLayerConstruct(this, "AuditConfigLayer", {
|
|
22
|
+
* apps: ["Orders", "Inventory"],
|
|
23
|
+
* resourceTypes: ["Order", "Product"],
|
|
24
|
+
* });
|
|
3
25
|
*
|
|
4
|
-
*
|
|
26
|
+
* // Pass auditLayer.layer to constructs that need it
|
|
27
|
+
* ```
|
|
5
28
|
*/
|
|
6
|
-
export
|
|
29
|
+
export class ConfigLayerConstruct extends Construct {
|
|
30
|
+
layer;
|
|
31
|
+
constructor(scope, id, props) {
|
|
32
|
+
super(scope, id);
|
|
33
|
+
// Generate config file content - exports raw data
|
|
34
|
+
// Handlers will call defineAuditConfig themselves
|
|
35
|
+
const configCode = `// Auto-generated audit configuration
|
|
36
|
+
export const apps = ${JSON.stringify(props.apps)};
|
|
37
|
+
export const resourceTypes = ${JSON.stringify(props.resourceTypes)};
|
|
38
|
+
`;
|
|
39
|
+
// Create temp directory with proper layer structure
|
|
40
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "audit-config-"));
|
|
41
|
+
const nodejsDir = path.join(tempDir, "nodejs");
|
|
42
|
+
fs.mkdirSync(nodejsDir);
|
|
43
|
+
fs.writeFileSync(path.join(nodejsDir, "audit-config.js"), configCode);
|
|
44
|
+
this.layer = new lambda.LayerVersion(this, "Layer", {
|
|
45
|
+
code: lambda.Code.fromAsset(tempDir),
|
|
46
|
+
compatibleRuntimes: [lambda.Runtime.NODEJS_20_X],
|
|
47
|
+
description: "Audit configuration layer containing apps and resourceTypes",
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -3,7 +3,7 @@ import * as iam from "aws-cdk-lib/aws-iam";
|
|
|
3
3
|
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
4
4
|
import * as nodejs from "aws-cdk-lib/aws-lambda-nodejs";
|
|
5
5
|
import * as logs from "aws-cdk-lib/aws-logs";
|
|
6
|
-
import { AUDIT_CONFIG_LAYER_PATH } from "./
|
|
6
|
+
import { AUDIT_CONFIG_LAYER_PATH } from "./construct.js";
|
|
7
7
|
/**
|
|
8
8
|
* Factory function that creates ESM Node.js Lambda functions with standard configuration.
|
|
9
9
|
*
|
package/package.json
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
2
|
-
import { Construct } from "constructs";
|
|
3
|
-
/**
|
|
4
|
-
* Input configuration for the audit config layer.
|
|
5
|
-
* Contains the apps and resource types that will be available to Lambda handlers.
|
|
6
|
-
*/
|
|
7
|
-
export interface AuditConfigLayerProps {
|
|
8
|
-
/** List of valid application identifiers */
|
|
9
|
-
readonly apps: readonly string[];
|
|
10
|
-
/** List of valid resource type identifiers */
|
|
11
|
-
readonly resourceTypes: readonly string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Path where handlers should import the audit config from.
|
|
15
|
-
* This is the standard Lambda layer path for Node.js.
|
|
16
|
-
*/
|
|
17
|
-
export declare const AUDIT_CONFIG_LAYER_PATH = "/opt/nodejs/audit-config.js";
|
|
18
|
-
/**
|
|
19
|
-
* Creates a Lambda layer containing the audit configuration.
|
|
20
|
-
*
|
|
21
|
-
* The layer exports raw `apps` and `resourceTypes` arrays that handlers
|
|
22
|
-
* can use with `defineAuditConfig` from the SDK.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { AuditConfigLayer } from "@flipboxlabs/aws-audit-cdk";
|
|
27
|
-
*
|
|
28
|
-
* const auditLayer = new AuditConfigLayer(this, "AuditConfigLayer", {
|
|
29
|
-
* apps: ["Orders", "Inventory"],
|
|
30
|
-
* resourceTypes: ["Order", "Product"],
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Pass auditLayer.layer to constructs that need it
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare class AuditConfigLayer extends Construct {
|
|
37
|
-
readonly layer: lambda.LayerVersion;
|
|
38
|
-
constructor(scope: Construct, id: string, props: AuditConfigLayerProps);
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=audit-config-layer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"audit-config-layer.d.ts","sourceRoot":"","sources":["../../src/lambda/audit-config-layer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;IAC9C,SAAgB,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC;gBAE/B,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB;CAuBtE"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as os from "node:os";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import * as lambda from "aws-cdk-lib/aws-lambda";
|
|
5
|
-
import { Construct } from "constructs";
|
|
6
|
-
/**
|
|
7
|
-
* Path where handlers should import the audit config from.
|
|
8
|
-
* This is the standard Lambda layer path for Node.js.
|
|
9
|
-
*/
|
|
10
|
-
export const AUDIT_CONFIG_LAYER_PATH = "/opt/nodejs/audit-config.js";
|
|
11
|
-
/**
|
|
12
|
-
* Creates a Lambda layer containing the audit configuration.
|
|
13
|
-
*
|
|
14
|
-
* The layer exports raw `apps` and `resourceTypes` arrays that handlers
|
|
15
|
-
* can use with `defineAuditConfig` from the SDK.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* import { AuditConfigLayer } from "@flipboxlabs/aws-audit-cdk";
|
|
20
|
-
*
|
|
21
|
-
* const auditLayer = new AuditConfigLayer(this, "AuditConfigLayer", {
|
|
22
|
-
* apps: ["Orders", "Inventory"],
|
|
23
|
-
* resourceTypes: ["Order", "Product"],
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* // Pass auditLayer.layer to constructs that need it
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export class AuditConfigLayer extends Construct {
|
|
30
|
-
layer;
|
|
31
|
-
constructor(scope, id, props) {
|
|
32
|
-
super(scope, id);
|
|
33
|
-
// Generate config file content - exports raw data
|
|
34
|
-
// Handlers will call defineAuditConfig themselves
|
|
35
|
-
const configCode = `// Auto-generated audit configuration
|
|
36
|
-
export const apps = ${JSON.stringify(props.apps)};
|
|
37
|
-
export const resourceTypes = ${JSON.stringify(props.resourceTypes)};
|
|
38
|
-
`;
|
|
39
|
-
// Create temp directory with proper layer structure
|
|
40
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "audit-config-"));
|
|
41
|
-
const nodejsDir = path.join(tempDir, "nodejs");
|
|
42
|
-
fs.mkdirSync(nodejsDir);
|
|
43
|
-
fs.writeFileSync(path.join(nodejsDir, "audit-config.js"), configCode);
|
|
44
|
-
this.layer = new lambda.LayerVersion(this, "Layer", {
|
|
45
|
-
code: lambda.Code.fromAsset(tempDir),
|
|
46
|
-
compatibleRuntimes: [lambda.Runtime.NODEJS_20_X],
|
|
47
|
-
description: "Audit configuration layer containing apps and resourceTypes",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|