@gugananuvem/aws-local-simulator 1.0.15 → 1.0.16
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 +789 -594
- package/bin/aws-local-simulator.js +63 -63
- package/package.json +2 -2
- package/src/config/config-loader.js +114 -114
- package/src/config/default-config.js +68 -68
- package/src/config/env-loader.js +68 -68
- package/src/index.js +146 -146
- package/src/index.mjs +123 -123
- package/src/server.js +227 -227
- package/src/services/apigateway/index.js +75 -73
- package/src/services/apigateway/server.js +570 -507
- package/src/services/apigateway/simulator.js +1261 -1261
- package/src/services/athena/index.js +75 -75
- package/src/services/athena/server.js +101 -101
- package/src/services/athena/simulador.js +998 -998
- package/src/services/athena/simulator.js +346 -346
- package/src/services/cloudformation/index.js +106 -106
- package/src/services/cloudformation/server.js +417 -417
- package/src/services/cloudformation/simulador.js +1045 -1045
- package/src/services/cloudtrail/index.js +84 -84
- package/src/services/cloudtrail/server.js +235 -235
- package/src/services/cloudtrail/simulador.js +719 -719
- package/src/services/cloudwatch/index.js +84 -84
- package/src/services/cloudwatch/server.js +366 -366
- package/src/services/cloudwatch/simulador.js +1173 -1173
- package/src/services/cognito/index.js +79 -79
- package/src/services/cognito/server.js +301 -301
- package/src/services/cognito/simulator.js +1655 -1655
- package/src/services/config/index.js +96 -96
- package/src/services/config/server.js +215 -215
- package/src/services/config/simulador.js +1260 -1260
- package/src/services/dynamodb/index.js +74 -74
- package/src/services/dynamodb/server.js +125 -125
- package/src/services/dynamodb/simulator.js +630 -630
- package/src/services/ecs/index.js +65 -65
- package/src/services/ecs/server.js +235 -235
- package/src/services/ecs/simulator.js +844 -844
- package/src/services/eventbridge/index.js +89 -89
- package/src/services/eventbridge/server.js +209 -209
- package/src/services/eventbridge/simulator.js +684 -684
- package/src/services/index.js +45 -45
- package/src/services/kms/index.js +75 -75
- package/src/services/kms/server.js +67 -67
- package/src/services/kms/simulator.js +324 -324
- package/src/services/lambda/handler-loader.js +183 -183
- package/src/services/lambda/index.js +78 -78
- package/src/services/lambda/route-registry.js +274 -274
- package/src/services/lambda/server.js +145 -145
- package/src/services/lambda/simulator.js +199 -199
- package/src/services/parameter-store/index.js +80 -80
- package/src/services/parameter-store/server.js +50 -50
- package/src/services/parameter-store/simulator.js +201 -201
- package/src/services/s3/index.js +73 -73
- package/src/services/s3/server.js +329 -329
- package/src/services/s3/simulator.js +565 -565
- package/src/services/secret-manager/index.js +80 -80
- package/src/services/secret-manager/server.js +50 -50
- package/src/services/secret-manager/simulator.js +171 -171
- package/src/services/sns/index.js +89 -89
- package/src/services/sns/server.js +580 -580
- package/src/services/sns/simulator.js +1482 -1482
- package/src/services/sqs/index.js +98 -93
- package/src/services/sqs/server.js +349 -349
- package/src/services/sqs/simulator.js +441 -441
- package/src/services/sts/index.js +37 -37
- package/src/services/sts/server.js +144 -144
- package/src/services/sts/simulator.js +69 -69
- package/src/services/xray/index.js +83 -83
- package/src/services/xray/server.js +308 -308
- package/src/services/xray/simulador.js +994 -994
- package/src/template/aws-config-template.js +87 -87
- package/src/template/aws-config-template.mjs +90 -90
- package/src/template/config-template.json +203 -203
- package/src/utils/aws-config.js +91 -91
- package/src/utils/cloudtrail-audit.js +129 -129
- package/src/utils/local-store.js +83 -83
- package/src/utils/logger.js +59 -59
package/src/services/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Barrel export para todos os serviços
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const DynamoDBService = require('./dynamodb');
|
|
6
|
-
const S3Service = require('./s3');
|
|
7
|
-
const SQSService = require('./sqs');
|
|
8
|
-
const LambdaService = require('./lambda');
|
|
9
|
-
const CognitoService = require('./cognito');
|
|
10
|
-
const APIGatewayService = require('./apigateway');
|
|
11
|
-
const ECSService = require('./ecs');
|
|
12
|
-
const STSService = require('./sts');
|
|
13
|
-
const { SNSService } = require('./sns');
|
|
14
|
-
const { EventBridgeService } = require('./eventbridge');
|
|
15
|
-
const { CloudWatchService } = require('./cloudwatch');
|
|
16
|
-
const CloudTrailService = require('./cloudtrail');
|
|
17
|
-
const { KMSService } = require('./kms');
|
|
18
|
-
const CloudFormationService = require('./cloudformation');
|
|
19
|
-
const { XRayService } = require('./xray');
|
|
20
|
-
const { SecretManagerService } = require('./secret-manager');
|
|
21
|
-
const { ParameterStoreService } = require('./parameter-store');
|
|
22
|
-
const { ConfigService } = require('./config');
|
|
23
|
-
const { AthenaService } = require('./athena');
|
|
24
|
-
|
|
25
|
-
module.exports = {
|
|
26
|
-
DynamoDBService,
|
|
27
|
-
S3Service,
|
|
28
|
-
SQSService,
|
|
29
|
-
LambdaService,
|
|
30
|
-
CognitoService,
|
|
31
|
-
APIGatewayService,
|
|
32
|
-
ECSService,
|
|
33
|
-
STSService,
|
|
34
|
-
SNSService,
|
|
35
|
-
EventBridgeService,
|
|
36
|
-
CloudWatchService,
|
|
37
|
-
CloudTrailService,
|
|
38
|
-
KMSService,
|
|
39
|
-
CloudFormationService,
|
|
40
|
-
XRayService,
|
|
41
|
-
SecretManagerService,
|
|
42
|
-
ParameterStoreService,
|
|
43
|
-
ConfigService,
|
|
44
|
-
AthenaService,
|
|
45
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Barrel export para todos os serviços
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const DynamoDBService = require('./dynamodb');
|
|
6
|
+
const S3Service = require('./s3');
|
|
7
|
+
const SQSService = require('./sqs');
|
|
8
|
+
const LambdaService = require('./lambda');
|
|
9
|
+
const CognitoService = require('./cognito');
|
|
10
|
+
const APIGatewayService = require('./apigateway');
|
|
11
|
+
const ECSService = require('./ecs');
|
|
12
|
+
const STSService = require('./sts');
|
|
13
|
+
const { SNSService } = require('./sns');
|
|
14
|
+
const { EventBridgeService } = require('./eventbridge');
|
|
15
|
+
const { CloudWatchService } = require('./cloudwatch');
|
|
16
|
+
const CloudTrailService = require('./cloudtrail');
|
|
17
|
+
const { KMSService } = require('./kms');
|
|
18
|
+
const CloudFormationService = require('./cloudformation');
|
|
19
|
+
const { XRayService } = require('./xray');
|
|
20
|
+
const { SecretManagerService } = require('./secret-manager');
|
|
21
|
+
const { ParameterStoreService } = require('./parameter-store');
|
|
22
|
+
const { ConfigService } = require('./config');
|
|
23
|
+
const { AthenaService } = require('./athena');
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
DynamoDBService,
|
|
27
|
+
S3Service,
|
|
28
|
+
SQSService,
|
|
29
|
+
LambdaService,
|
|
30
|
+
CognitoService,
|
|
31
|
+
APIGatewayService,
|
|
32
|
+
ECSService,
|
|
33
|
+
STSService,
|
|
34
|
+
SNSService,
|
|
35
|
+
EventBridgeService,
|
|
36
|
+
CloudWatchService,
|
|
37
|
+
CloudTrailService,
|
|
38
|
+
KMSService,
|
|
39
|
+
CloudFormationService,
|
|
40
|
+
XRayService,
|
|
41
|
+
SecretManagerService,
|
|
42
|
+
ParameterStoreService,
|
|
43
|
+
ConfigService,
|
|
44
|
+
AthenaService,
|
|
45
|
+
};
|
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const http = require('http');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const { KMSSimulator } = require('./simulator');
|
|
6
|
-
const { KMSServer } = require('./server');
|
|
7
|
-
const LocalStore = require('../../utils/local-store');
|
|
8
|
-
|
|
9
|
-
class KMSService {
|
|
10
|
-
constructor(config) {
|
|
11
|
-
this.config = config;
|
|
12
|
-
this.logger = require('../../utils/logger');
|
|
13
|
-
this.name = 'kms';
|
|
14
|
-
this.port = config?.ports?.kms || config?.services?.kms?.port || 4000;
|
|
15
|
-
this.store = null;
|
|
16
|
-
this.simulator = null;
|
|
17
|
-
this.httpServer = null;
|
|
18
|
-
this.isRunning = false;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async initialize() {
|
|
22
|
-
this.logger.debug(`Inicializando KMS Service na porta ${this.port}...`);
|
|
23
|
-
const dataDir = process.env.AWS_LOCAL_SIMULATOR_DATA_DIR;
|
|
24
|
-
this.store = new LocalStore(path.join(dataDir, 'kms'));
|
|
25
|
-
this.simulator = new KMSSimulator(this.store, this.logger, this.config);
|
|
26
|
-
await this.simulator.initialize();
|
|
27
|
-
this.app = new KMSServer(this.simulator, this.logger, this.config).getApp();
|
|
28
|
-
this.logger.debug('KMS Service inicializado');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
injectDependencies(server) {
|
|
32
|
-
const ct = server.getService('cloudtrail');
|
|
33
|
-
if (ct?.simulator) this.simulator.audit.setTrail(ct.simulator);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async start() {
|
|
37
|
-
if (this.isRunning) return;
|
|
38
|
-
return new Promise((resolve, reject) => {
|
|
39
|
-
this.httpServer = http.createServer(this.app);
|
|
40
|
-
this.httpServer.listen(this.port, () => {
|
|
41
|
-
this.isRunning = true;
|
|
42
|
-
this.logger.debug(`KMS rodando na porta ${this.port}`);
|
|
43
|
-
resolve();
|
|
44
|
-
});
|
|
45
|
-
this.httpServer.on('error', reject);
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async stop() {
|
|
50
|
-
if (!this.isRunning || !this.httpServer) return;
|
|
51
|
-
return new Promise((resolve) => {
|
|
52
|
-
this.httpServer.close(() => {
|
|
53
|
-
this.isRunning = false;
|
|
54
|
-
resolve();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async reset() {
|
|
60
|
-
await this.simulator.reset();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
getStatus() {
|
|
64
|
-
return {
|
|
65
|
-
running: this.isRunning,
|
|
66
|
-
port: this.port,
|
|
67
|
-
endpoint: `http://localhost:${this.port}`,
|
|
68
|
-
keys: this.simulator?.keys.size || 0,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
getSimulator() { return this.simulator; }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
module.exports = { KMSService };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { KMSSimulator } = require('./simulator');
|
|
6
|
+
const { KMSServer } = require('./server');
|
|
7
|
+
const LocalStore = require('../../utils/local-store');
|
|
8
|
+
|
|
9
|
+
class KMSService {
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.logger = require('../../utils/logger');
|
|
13
|
+
this.name = 'kms';
|
|
14
|
+
this.port = config?.ports?.kms || config?.services?.kms?.port || 4000;
|
|
15
|
+
this.store = null;
|
|
16
|
+
this.simulator = null;
|
|
17
|
+
this.httpServer = null;
|
|
18
|
+
this.isRunning = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async initialize() {
|
|
22
|
+
this.logger.debug(`Inicializando KMS Service na porta ${this.port}...`);
|
|
23
|
+
const dataDir = process.env.AWS_LOCAL_SIMULATOR_DATA_DIR;
|
|
24
|
+
this.store = new LocalStore(path.join(dataDir, 'kms'));
|
|
25
|
+
this.simulator = new KMSSimulator(this.store, this.logger, this.config);
|
|
26
|
+
await this.simulator.initialize();
|
|
27
|
+
this.app = new KMSServer(this.simulator, this.logger, this.config).getApp();
|
|
28
|
+
this.logger.debug('KMS Service inicializado');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
injectDependencies(server) {
|
|
32
|
+
const ct = server.getService('cloudtrail');
|
|
33
|
+
if (ct?.simulator) this.simulator.audit.setTrail(ct.simulator);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async start() {
|
|
37
|
+
if (this.isRunning) return;
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
this.httpServer = http.createServer(this.app);
|
|
40
|
+
this.httpServer.listen(this.port, () => {
|
|
41
|
+
this.isRunning = true;
|
|
42
|
+
this.logger.debug(`KMS rodando na porta ${this.port}`);
|
|
43
|
+
resolve();
|
|
44
|
+
});
|
|
45
|
+
this.httpServer.on('error', reject);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async stop() {
|
|
50
|
+
if (!this.isRunning || !this.httpServer) return;
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
this.httpServer.close(() => {
|
|
53
|
+
this.isRunning = false;
|
|
54
|
+
resolve();
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async reset() {
|
|
60
|
+
await this.simulator.reset();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getStatus() {
|
|
64
|
+
return {
|
|
65
|
+
running: this.isRunning,
|
|
66
|
+
port: this.port,
|
|
67
|
+
endpoint: `http://localhost:${this.port}`,
|
|
68
|
+
keys: this.simulator?.keys.size || 0,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
getSimulator() { return this.simulator; }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
module.exports = { KMSService };
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const express = require('express');
|
|
4
|
-
const cors = require('cors');
|
|
5
|
-
|
|
6
|
-
class KMSServer {
|
|
7
|
-
constructor(simulator, logger, config) {
|
|
8
|
-
this.simulator = simulator;
|
|
9
|
-
this.logger = logger;
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.app = express();
|
|
12
|
-
this._setupMiddleware();
|
|
13
|
-
this._setupRoutes();
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
_setupMiddleware() {
|
|
17
|
-
if (this.config.cors?.enabled !== false) this.app.use(cors({ origin: this.config.cors?.origin || '*' }));
|
|
18
|
-
this.app.use(express.json({ limit: '5mb', type: ['application/json', 'application/x-amz-json-1.1'] }));
|
|
19
|
-
this.app.use((req, res, next) => { this.logger.debug(`KMS ${req.headers['x-amz-target']}`, 'kms'); next(); });
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_getOperation(target) {
|
|
23
|
-
const map = {
|
|
24
|
-
'TrentService.CreateKey': 'createKey',
|
|
25
|
-
'TrentService.DescribeKey': 'describeKey',
|
|
26
|
-
'TrentService.ListKeys': 'listKeys',
|
|
27
|
-
'TrentService.EnableKey': 'enableKey',
|
|
28
|
-
'TrentService.DisableKey': 'disableKey',
|
|
29
|
-
'TrentService.ScheduleKeyDeletion': 'scheduleKeyDeletion',
|
|
30
|
-
'TrentService.CancelKeyDeletion': 'cancelKeyDeletion',
|
|
31
|
-
'TrentService.CreateAlias': 'createAlias',
|
|
32
|
-
'TrentService.DeleteAlias': 'deleteAlias',
|
|
33
|
-
'TrentService.ListAliases': 'listAliases',
|
|
34
|
-
'TrentService.Encrypt': 'encrypt',
|
|
35
|
-
'TrentService.Decrypt': 'decrypt',
|
|
36
|
-
'TrentService.GenerateDataKey': 'generateDataKey',
|
|
37
|
-
'TrentService.GenerateDataKeyWithoutPlaintext': 'generateDataKeyWithoutPlaintext',
|
|
38
|
-
'TrentService.GenerateDataKeyPair': 'generateDataKeyPair',
|
|
39
|
-
'TrentService.Sign': 'sign',
|
|
40
|
-
'TrentService.Verify': 'verify',
|
|
41
|
-
'TrentService.GenerateRandom': 'generateRandom',
|
|
42
|
-
};
|
|
43
|
-
return map[target];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
_setupRoutes() {
|
|
47
|
-
this.app.get('/__admin/health', (req, res) => res.json({ status: 'healthy', service: 'kms', timestamp: new Date().toISOString() }));
|
|
48
|
-
this.app.get('/__admin/keys', async (req, res) => { const r = await this.simulator.listKeys({}); res.json(r); });
|
|
49
|
-
|
|
50
|
-
this.app.post('/', async (req, res) => {
|
|
51
|
-
const target = req.headers['x-amz-target'];
|
|
52
|
-
const operation = this._getOperation(target);
|
|
53
|
-
if (!operation) return res.status(400).json({ __type: 'UnknownOperationException', message: `Unknown: ${target}` });
|
|
54
|
-
try {
|
|
55
|
-
const result = await this.simulator[operation](req.body || {});
|
|
56
|
-
res.json(result || {});
|
|
57
|
-
} catch (err) {
|
|
58
|
-
this.logger.error(`KMS ${target}: ${err.message}`, 'kms');
|
|
59
|
-
res.status(err.code === 'NotFoundException' ? 404 : 400).json({ __type: err.code || 'KMSInternalException', message: err.message });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
getApp() { return this.app; }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = { KMSServer };
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const express = require('express');
|
|
4
|
+
const cors = require('cors');
|
|
5
|
+
|
|
6
|
+
class KMSServer {
|
|
7
|
+
constructor(simulator, logger, config) {
|
|
8
|
+
this.simulator = simulator;
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.app = express();
|
|
12
|
+
this._setupMiddleware();
|
|
13
|
+
this._setupRoutes();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
_setupMiddleware() {
|
|
17
|
+
if (this.config.cors?.enabled !== false) this.app.use(cors({ origin: this.config.cors?.origin || '*' }));
|
|
18
|
+
this.app.use(express.json({ limit: '5mb', type: ['application/json', 'application/x-amz-json-1.1'] }));
|
|
19
|
+
this.app.use((req, res, next) => { this.logger.debug(`KMS ${req.headers['x-amz-target']}`, 'kms'); next(); });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_getOperation(target) {
|
|
23
|
+
const map = {
|
|
24
|
+
'TrentService.CreateKey': 'createKey',
|
|
25
|
+
'TrentService.DescribeKey': 'describeKey',
|
|
26
|
+
'TrentService.ListKeys': 'listKeys',
|
|
27
|
+
'TrentService.EnableKey': 'enableKey',
|
|
28
|
+
'TrentService.DisableKey': 'disableKey',
|
|
29
|
+
'TrentService.ScheduleKeyDeletion': 'scheduleKeyDeletion',
|
|
30
|
+
'TrentService.CancelKeyDeletion': 'cancelKeyDeletion',
|
|
31
|
+
'TrentService.CreateAlias': 'createAlias',
|
|
32
|
+
'TrentService.DeleteAlias': 'deleteAlias',
|
|
33
|
+
'TrentService.ListAliases': 'listAliases',
|
|
34
|
+
'TrentService.Encrypt': 'encrypt',
|
|
35
|
+
'TrentService.Decrypt': 'decrypt',
|
|
36
|
+
'TrentService.GenerateDataKey': 'generateDataKey',
|
|
37
|
+
'TrentService.GenerateDataKeyWithoutPlaintext': 'generateDataKeyWithoutPlaintext',
|
|
38
|
+
'TrentService.GenerateDataKeyPair': 'generateDataKeyPair',
|
|
39
|
+
'TrentService.Sign': 'sign',
|
|
40
|
+
'TrentService.Verify': 'verify',
|
|
41
|
+
'TrentService.GenerateRandom': 'generateRandom',
|
|
42
|
+
};
|
|
43
|
+
return map[target];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_setupRoutes() {
|
|
47
|
+
this.app.get('/__admin/health', (req, res) => res.json({ status: 'healthy', service: 'kms', timestamp: new Date().toISOString() }));
|
|
48
|
+
this.app.get('/__admin/keys', async (req, res) => { const r = await this.simulator.listKeys({}); res.json(r); });
|
|
49
|
+
|
|
50
|
+
this.app.post('/', async (req, res) => {
|
|
51
|
+
const target = req.headers['x-amz-target'];
|
|
52
|
+
const operation = this._getOperation(target);
|
|
53
|
+
if (!operation) return res.status(400).json({ __type: 'UnknownOperationException', message: `Unknown: ${target}` });
|
|
54
|
+
try {
|
|
55
|
+
const result = await this.simulator[operation](req.body || {});
|
|
56
|
+
res.json(result || {});
|
|
57
|
+
} catch (err) {
|
|
58
|
+
this.logger.error(`KMS ${target}: ${err.message}`, 'kms');
|
|
59
|
+
res.status(err.code === 'NotFoundException' ? 404 : 400).json({ __type: err.code || 'KMSInternalException', message: err.message });
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getApp() { return this.app; }
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
module.exports = { KMSServer };
|