@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
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* CLI para AWS Local Simulator
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { AWSLocalSimulator } = require('../src/index');
|
|
8
|
-
const logger = require('../src/utils/logger');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
const command = process.argv[2];
|
|
12
|
-
const configPath = process.argv[3];
|
|
13
|
-
|
|
14
|
-
const simulator = new AWSLocalSimulator({
|
|
15
|
-
configPath: configPath ? path.resolve(process.cwd(), configPath) : undefined
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
async function main() {
|
|
19
|
-
switch (command) {
|
|
20
|
-
case 'start':
|
|
21
|
-
await simulator.start();
|
|
22
|
-
break;
|
|
23
|
-
|
|
24
|
-
case 'stop':
|
|
25
|
-
await simulator.stop();
|
|
26
|
-
break;
|
|
27
|
-
|
|
28
|
-
case 'restart':
|
|
29
|
-
await simulator.restart();
|
|
30
|
-
break;
|
|
31
|
-
|
|
32
|
-
case 'reset':
|
|
33
|
-
await simulator.reset();
|
|
34
|
-
break;
|
|
35
|
-
|
|
36
|
-
case 'status':
|
|
37
|
-
const status = simulator.getStatus();
|
|
38
|
-
console.log(JSON.stringify(status, null, 2));
|
|
39
|
-
break;
|
|
40
|
-
|
|
41
|
-
case 'help':
|
|
42
|
-
default:
|
|
43
|
-
console.log(`
|
|
44
|
-
AWS Local Simulator - CLI Commands:
|
|
45
|
-
start [configPath] - Inicia o simulador
|
|
46
|
-
stop - Para o simulador
|
|
47
|
-
restart - Reinicia o simulador
|
|
48
|
-
reset - Reseta todos os dados
|
|
49
|
-
status - Mostra status dos serviços
|
|
50
|
-
help - Mostra esta ajuda
|
|
51
|
-
|
|
52
|
-
Exemplos:
|
|
53
|
-
npx aws-local-simulator start
|
|
54
|
-
npx aws-local-simulator start ./my-config.json
|
|
55
|
-
AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
|
|
56
|
-
`);
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
main().catch(error => {
|
|
62
|
-
logger.error('Erro:', error);
|
|
63
|
-
process.exit(1);
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* CLI para AWS Local Simulator
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const { AWSLocalSimulator } = require('../src/index');
|
|
8
|
+
const logger = require('../src/utils/logger');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
const command = process.argv[2];
|
|
12
|
+
const configPath = process.argv[3];
|
|
13
|
+
|
|
14
|
+
const simulator = new AWSLocalSimulator({
|
|
15
|
+
configPath: configPath ? path.resolve(process.cwd(), configPath) : undefined
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
async function main() {
|
|
19
|
+
switch (command) {
|
|
20
|
+
case 'start':
|
|
21
|
+
await simulator.start();
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
case 'stop':
|
|
25
|
+
await simulator.stop();
|
|
26
|
+
break;
|
|
27
|
+
|
|
28
|
+
case 'restart':
|
|
29
|
+
await simulator.restart();
|
|
30
|
+
break;
|
|
31
|
+
|
|
32
|
+
case 'reset':
|
|
33
|
+
await simulator.reset();
|
|
34
|
+
break;
|
|
35
|
+
|
|
36
|
+
case 'status':
|
|
37
|
+
const status = simulator.getStatus();
|
|
38
|
+
console.log(JSON.stringify(status, null, 2));
|
|
39
|
+
break;
|
|
40
|
+
|
|
41
|
+
case 'help':
|
|
42
|
+
default:
|
|
43
|
+
console.log(`
|
|
44
|
+
AWS Local Simulator - CLI Commands:
|
|
45
|
+
start [configPath] - Inicia o simulador
|
|
46
|
+
stop - Para o simulador
|
|
47
|
+
restart - Reinicia o simulador
|
|
48
|
+
reset - Reseta todos os dados
|
|
49
|
+
status - Mostra status dos serviços
|
|
50
|
+
help - Mostra esta ajuda
|
|
51
|
+
|
|
52
|
+
Exemplos:
|
|
53
|
+
npx aws-local-simulator start
|
|
54
|
+
npx aws-local-simulator start ./my-config.json
|
|
55
|
+
AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
|
|
56
|
+
`);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
main().catch(error => {
|
|
62
|
+
logger.error('Erro:', error);
|
|
63
|
+
process.exit(1);
|
|
64
64
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gugananuvem/aws-local-simulator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Simulador local completo para serviços AWS",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"optional": true
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"buildDate": "2026-04-
|
|
123
|
+
"buildDate": "2026-04-20T18:31:32.841Z",
|
|
124
124
|
"published": true
|
|
125
125
|
}
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Carrega configurações do usuário
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const fs = require('fs');
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const defaultConfig = require('./default-config');
|
|
8
|
-
const EnvLoader = require('./env-loader');
|
|
9
|
-
const logger = require('../utils/logger');
|
|
10
|
-
|
|
11
|
-
class ConfigLoader {
|
|
12
|
-
static async load(configPath) {
|
|
13
|
-
logger.info('📝 Carregando configurações...');
|
|
14
|
-
|
|
15
|
-
// 1. Carrega configurações padrão
|
|
16
|
-
let config = { ...defaultConfig };
|
|
17
|
-
|
|
18
|
-
// 2. Sobrescreve com variáveis de ambiente
|
|
19
|
-
const envConfig = EnvLoader.load();
|
|
20
|
-
config = this.mergeDeep(config, envConfig);
|
|
21
|
-
|
|
22
|
-
// 3. Sobrescreve com arquivo de configuração do usuário se existir
|
|
23
|
-
if (configPath) {
|
|
24
|
-
const userConfig = await this.loadUserConfig(configPath);
|
|
25
|
-
config = this.mergeDeep(config, userConfig);
|
|
26
|
-
config._configPath = path.resolve(process.cwd(), configPath);
|
|
27
|
-
} else {
|
|
28
|
-
// Tenta encontrar arquivo de configuração padrão
|
|
29
|
-
const possiblePaths = [
|
|
30
|
-
path.join(process.cwd(), 'aws-local-simulator.json'),
|
|
31
|
-
path.join(process.cwd(), 'aws-local-simulator.config.json'),
|
|
32
|
-
path.join(process.cwd(), '.aws-local-simulator.json')
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
for (const possiblePath of possiblePaths) {
|
|
36
|
-
if (fs.existsSync(possiblePath)) {
|
|
37
|
-
const userConfig = await this.loadUserConfig(possiblePath);
|
|
38
|
-
config = this.mergeDeep(config, userConfig);
|
|
39
|
-
config._configPath = possiblePath;
|
|
40
|
-
logger.info(`✅ Configuração carregada de: ${possiblePath}`);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// 4. Valida configurações
|
|
47
|
-
this.validate(config);
|
|
48
|
-
|
|
49
|
-
logger.info(`✅ Configurações carregadas (logLevel: ${config.logLevel})`);
|
|
50
|
-
|
|
51
|
-
return config;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static async loadUserConfig(filePath) {
|
|
55
|
-
try {
|
|
56
|
-
const fullPath = path.resolve(process.cwd(), filePath);
|
|
57
|
-
|
|
58
|
-
if (!fs.existsSync(fullPath)) {
|
|
59
|
-
logger.warn(`Arquivo de configuração não encontrado: ${fullPath}`);
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const content = fs.readFileSync(fullPath, 'utf8');
|
|
64
|
-
const config = JSON.parse(content);
|
|
65
|
-
|
|
66
|
-
return config;
|
|
67
|
-
} catch (error) {
|
|
68
|
-
logger.error(`Erro ao carregar configuração de ${filePath}:`, error);
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
static validate(config) {
|
|
74
|
-
// Valida serviços
|
|
75
|
-
const enabledServices = Object.entries(config.services)
|
|
76
|
-
.filter(([_, enabled]) => enabled)
|
|
77
|
-
.map(([name]) => name);
|
|
78
|
-
|
|
79
|
-
if (enabledServices.length === 0) {
|
|
80
|
-
logger.warn('⚠️ Nenhum serviço está habilitado!');
|
|
81
|
-
} else {
|
|
82
|
-
logger.info(`📦 Serviços habilitados: ${enabledServices.join(', ')}`);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Valida diretório de dados
|
|
86
|
-
if (!config.dataDir) {
|
|
87
|
-
throw new Error('dataDir não configurado');
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Valida portas
|
|
91
|
-
for (const [service, port] of Object.entries(config.ports)) {
|
|
92
|
-
if (config.services[service] && (port < 1 || port > 65535)) {
|
|
93
|
-
throw new Error(`Porta inválida para ${service}: ${port}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static mergeDeep(target, source) {
|
|
99
|
-
const output = { ...target };
|
|
100
|
-
|
|
101
|
-
for (const key in source) {
|
|
102
|
-
if (source.hasOwnProperty(key)) {
|
|
103
|
-
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
104
|
-
output[key] = this.mergeDeep(target[key] || {}, source[key]);
|
|
105
|
-
} else {
|
|
106
|
-
output[key] = source[key];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return output;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Carrega configurações do usuário
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const defaultConfig = require('./default-config');
|
|
8
|
+
const EnvLoader = require('./env-loader');
|
|
9
|
+
const logger = require('../utils/logger');
|
|
10
|
+
|
|
11
|
+
class ConfigLoader {
|
|
12
|
+
static async load(configPath) {
|
|
13
|
+
logger.info('📝 Carregando configurações...');
|
|
14
|
+
|
|
15
|
+
// 1. Carrega configurações padrão
|
|
16
|
+
let config = { ...defaultConfig };
|
|
17
|
+
|
|
18
|
+
// 2. Sobrescreve com variáveis de ambiente
|
|
19
|
+
const envConfig = EnvLoader.load();
|
|
20
|
+
config = this.mergeDeep(config, envConfig);
|
|
21
|
+
|
|
22
|
+
// 3. Sobrescreve com arquivo de configuração do usuário se existir
|
|
23
|
+
if (configPath) {
|
|
24
|
+
const userConfig = await this.loadUserConfig(configPath);
|
|
25
|
+
config = this.mergeDeep(config, userConfig);
|
|
26
|
+
config._configPath = path.resolve(process.cwd(), configPath);
|
|
27
|
+
} else {
|
|
28
|
+
// Tenta encontrar arquivo de configuração padrão
|
|
29
|
+
const possiblePaths = [
|
|
30
|
+
path.join(process.cwd(), 'aws-local-simulator.json'),
|
|
31
|
+
path.join(process.cwd(), 'aws-local-simulator.config.json'),
|
|
32
|
+
path.join(process.cwd(), '.aws-local-simulator.json')
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
for (const possiblePath of possiblePaths) {
|
|
36
|
+
if (fs.existsSync(possiblePath)) {
|
|
37
|
+
const userConfig = await this.loadUserConfig(possiblePath);
|
|
38
|
+
config = this.mergeDeep(config, userConfig);
|
|
39
|
+
config._configPath = possiblePath;
|
|
40
|
+
logger.info(`✅ Configuração carregada de: ${possiblePath}`);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 4. Valida configurações
|
|
47
|
+
this.validate(config);
|
|
48
|
+
|
|
49
|
+
logger.info(`✅ Configurações carregadas (logLevel: ${config.logLevel})`);
|
|
50
|
+
|
|
51
|
+
return config;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static async loadUserConfig(filePath) {
|
|
55
|
+
try {
|
|
56
|
+
const fullPath = path.resolve(process.cwd(), filePath);
|
|
57
|
+
|
|
58
|
+
if (!fs.existsSync(fullPath)) {
|
|
59
|
+
logger.warn(`Arquivo de configuração não encontrado: ${fullPath}`);
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const content = fs.readFileSync(fullPath, 'utf8');
|
|
64
|
+
const config = JSON.parse(content);
|
|
65
|
+
|
|
66
|
+
return config;
|
|
67
|
+
} catch (error) {
|
|
68
|
+
logger.error(`Erro ao carregar configuração de ${filePath}:`, error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static validate(config) {
|
|
74
|
+
// Valida serviços
|
|
75
|
+
const enabledServices = Object.entries(config.services)
|
|
76
|
+
.filter(([_, enabled]) => enabled)
|
|
77
|
+
.map(([name]) => name);
|
|
78
|
+
|
|
79
|
+
if (enabledServices.length === 0) {
|
|
80
|
+
logger.warn('⚠️ Nenhum serviço está habilitado!');
|
|
81
|
+
} else {
|
|
82
|
+
logger.info(`📦 Serviços habilitados: ${enabledServices.join(', ')}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Valida diretório de dados
|
|
86
|
+
if (!config.dataDir) {
|
|
87
|
+
throw new Error('dataDir não configurado');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Valida portas
|
|
91
|
+
for (const [service, port] of Object.entries(config.ports)) {
|
|
92
|
+
if (config.services[service] && (port < 1 || port > 65535)) {
|
|
93
|
+
throw new Error(`Porta inválida para ${service}: ${port}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static mergeDeep(target, source) {
|
|
99
|
+
const output = { ...target };
|
|
100
|
+
|
|
101
|
+
for (const key in source) {
|
|
102
|
+
if (source.hasOwnProperty(key)) {
|
|
103
|
+
if (source[key] && typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
104
|
+
output[key] = this.mergeDeep(target[key] || {}, source[key]);
|
|
105
|
+
} else {
|
|
106
|
+
output[key] = source[key];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return output;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
115
|
module.exports = { loadConfig: ConfigLoader.load.bind(ConfigLoader) };
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configurações padrão do simulador
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
// Serviços habilitados por padrão
|
|
7
|
-
services: {
|
|
8
|
-
dynamodb: true,
|
|
9
|
-
s3: true,
|
|
10
|
-
sqs: true,
|
|
11
|
-
lambda: true,
|
|
12
|
-
sns: false,
|
|
13
|
-
eventbridge: false,
|
|
14
|
-
ecs: false,
|
|
15
|
-
cognito: false,
|
|
16
|
-
apigateway: false,
|
|
17
|
-
sts: true,
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
// Portas padrão
|
|
21
|
-
ports: {
|
|
22
|
-
dynamodb: 8000,
|
|
23
|
-
s3: 4566,
|
|
24
|
-
sqs: 9324,
|
|
25
|
-
lambda: 3001,
|
|
26
|
-
sns: 9911,
|
|
27
|
-
eventbridge: 4010,
|
|
28
|
-
ecs: 8080,
|
|
29
|
-
cognito: 9229,
|
|
30
|
-
apigateway: 4567,
|
|
31
|
-
sts: 9326,
|
|
32
|
-
athena: 4599,
|
|
33
|
-
},
|
|
34
|
-
apigateway: {
|
|
35
|
-
defaultCors: {
|
|
36
|
-
allowOrigins: ["*"],
|
|
37
|
-
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
38
|
-
allowHeaders: ["*"],
|
|
39
|
-
maxAge: 300,
|
|
40
|
-
},
|
|
41
|
-
defaultThrottling: {
|
|
42
|
-
burstLimit: 100,
|
|
43
|
-
rateLimit: 10,
|
|
44
|
-
},
|
|
45
|
-
enableAccessLogging: true,
|
|
46
|
-
autoDeploy: true,
|
|
47
|
-
},
|
|
48
|
-
// Configurações de persistência
|
|
49
|
-
dataDir: "./.aws-local-simulator-data",
|
|
50
|
-
|
|
51
|
-
// Configurações de logging
|
|
52
|
-
logLevel: "info", // silent, info, debug, verboso
|
|
53
|
-
|
|
54
|
-
// Configurações das Lambdas
|
|
55
|
-
lambdas: [], // Será preenchido pelo usuário
|
|
56
|
-
|
|
57
|
-
// Configurações de CORS
|
|
58
|
-
cors: true,
|
|
59
|
-
|
|
60
|
-
// Auto-criação de tabelas DynamoDB
|
|
61
|
-
autoCreateTables: true,
|
|
62
|
-
|
|
63
|
-
// Auto-criação de buckets S3
|
|
64
|
-
autoCreateBuckets: true,
|
|
65
|
-
|
|
66
|
-
// Configurações adicionais
|
|
67
|
-
additional: {},
|
|
68
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Configurações padrão do simulador
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
// Serviços habilitados por padrão
|
|
7
|
+
services: {
|
|
8
|
+
dynamodb: true,
|
|
9
|
+
s3: true,
|
|
10
|
+
sqs: true,
|
|
11
|
+
lambda: true,
|
|
12
|
+
sns: false,
|
|
13
|
+
eventbridge: false,
|
|
14
|
+
ecs: false,
|
|
15
|
+
cognito: false,
|
|
16
|
+
apigateway: false,
|
|
17
|
+
sts: true,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// Portas padrão
|
|
21
|
+
ports: {
|
|
22
|
+
dynamodb: 8000,
|
|
23
|
+
s3: 4566,
|
|
24
|
+
sqs: 9324,
|
|
25
|
+
lambda: 3001,
|
|
26
|
+
sns: 9911,
|
|
27
|
+
eventbridge: 4010,
|
|
28
|
+
ecs: 8080,
|
|
29
|
+
cognito: 9229,
|
|
30
|
+
apigateway: 4567,
|
|
31
|
+
sts: 9326,
|
|
32
|
+
athena: 4599,
|
|
33
|
+
},
|
|
34
|
+
apigateway: {
|
|
35
|
+
defaultCors: {
|
|
36
|
+
allowOrigins: ["*"],
|
|
37
|
+
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
38
|
+
allowHeaders: ["*"],
|
|
39
|
+
maxAge: 300,
|
|
40
|
+
},
|
|
41
|
+
defaultThrottling: {
|
|
42
|
+
burstLimit: 100,
|
|
43
|
+
rateLimit: 10,
|
|
44
|
+
},
|
|
45
|
+
enableAccessLogging: true,
|
|
46
|
+
autoDeploy: true,
|
|
47
|
+
},
|
|
48
|
+
// Configurações de persistência
|
|
49
|
+
dataDir: "./.aws-local-simulator-data",
|
|
50
|
+
|
|
51
|
+
// Configurações de logging
|
|
52
|
+
logLevel: "info", // silent, info, debug, verboso
|
|
53
|
+
|
|
54
|
+
// Configurações das Lambdas
|
|
55
|
+
lambdas: [], // Será preenchido pelo usuário
|
|
56
|
+
|
|
57
|
+
// Configurações de CORS
|
|
58
|
+
cors: true,
|
|
59
|
+
|
|
60
|
+
// Auto-criação de tabelas DynamoDB
|
|
61
|
+
autoCreateTables: true,
|
|
62
|
+
|
|
63
|
+
// Auto-criação de buckets S3
|
|
64
|
+
autoCreateBuckets: true,
|
|
65
|
+
|
|
66
|
+
// Configurações adicionais
|
|
67
|
+
additional: {},
|
|
68
|
+
};
|
package/src/config/env-loader.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Carrega configurações de variáveis de ambiente
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const logger = require('../utils/logger');
|
|
6
|
-
|
|
7
|
-
class EnvLoader {
|
|
8
|
-
static load() {
|
|
9
|
-
const config = {};
|
|
10
|
-
|
|
11
|
-
// Carrega configuração de serviços
|
|
12
|
-
config.services = {
|
|
13
|
-
dynamodb: this.getEnvBool('AWS_LOCAL_SIMULATOR_DYNAMODB', true),
|
|
14
|
-
s3: this.getEnvBool('AWS_LOCAL_SIMULATOR_S3', true),
|
|
15
|
-
sqs: this.getEnvBool('AWS_LOCAL_SIMULATOR_SQS', true),
|
|
16
|
-
sns: this.getEnvBool('AWS_LOCAL_SIMULATOR_SNS', false),
|
|
17
|
-
lambda: this.getEnvBool('AWS_LOCAL_SIMULATOR_LAMBDA', true),
|
|
18
|
-
apigateway: this.getEnvBool('AWS_LOCAL_SIMULATOR_APIGATEWAY', false),
|
|
19
|
-
eventbridge: this.getEnvBool('AWS_LOCAL_SIMULATOR_EVENTBRIDGE', false)
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// Carrega portas
|
|
23
|
-
config.ports = {
|
|
24
|
-
dynamodb: this.getEnvInt('AWS_LOCAL_SIMULATOR_DYNAMODB_PORT', 8000),
|
|
25
|
-
s3: this.getEnvInt('AWS_LOCAL_SIMULATOR_S3_PORT', 4566),
|
|
26
|
-
sqs: this.getEnvInt('AWS_LOCAL_SIMULATOR_SQS_PORT', 9324),
|
|
27
|
-
lambda: this.getEnvInt('AWS_LOCAL_SIMULATOR_LAMBDA_PORT', 3001),
|
|
28
|
-
sns: this.getEnvInt('AWS_LOCAL_SIMULATOR_SNS_PORT', 9911),
|
|
29
|
-
apigateway: this.getEnvInt('AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT', 4567),
|
|
30
|
-
eventbridge: this.getEnvInt('AWS_LOCAL_SIMULATOR_EVENTBRIDGE_PORT', 4010)
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Carrega diretório de dados
|
|
34
|
-
config.dataDir = process.env.AWS_LOCAL_SIMULATOR_DATA || './.aws-local-simulator-data';
|
|
35
|
-
|
|
36
|
-
// Carrega nível de log
|
|
37
|
-
config.logLevel = process.env.AWS_LOCAL_SIMULATOR_LOG || 'info';
|
|
38
|
-
|
|
39
|
-
// Carrega CORS
|
|
40
|
-
config.cors = this.getEnvBool('AWS_LOCAL_SIMULATOR_CORS', true);
|
|
41
|
-
|
|
42
|
-
// Carrega auto-create
|
|
43
|
-
config.autoCreateTables = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_TABLES', true);
|
|
44
|
-
config.autoCreateBuckets = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_BUCKETS', true);
|
|
45
|
-
|
|
46
|
-
logger.debug('Variáveis de ambiente carregadas:', config);
|
|
47
|
-
|
|
48
|
-
return config;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
static getEnvBool(key, defaultValue) {
|
|
52
|
-
const value = process.env[key];
|
|
53
|
-
if (value === undefined) return defaultValue;
|
|
54
|
-
return value === 'true' || value === '1' || value === 'yes';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static getEnvInt(key, defaultValue) {
|
|
58
|
-
const value = process.env[key];
|
|
59
|
-
if (value === undefined) return defaultValue;
|
|
60
|
-
const parsed = parseInt(value, 10);
|
|
61
|
-
return isNaN(parsed) ? defaultValue : parsed;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static getEnvString(key, defaultValue) {
|
|
65
|
-
return process.env[key] || defaultValue;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Carrega configurações de variáveis de ambiente
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const logger = require('../utils/logger');
|
|
6
|
+
|
|
7
|
+
class EnvLoader {
|
|
8
|
+
static load() {
|
|
9
|
+
const config = {};
|
|
10
|
+
|
|
11
|
+
// Carrega configuração de serviços
|
|
12
|
+
config.services = {
|
|
13
|
+
dynamodb: this.getEnvBool('AWS_LOCAL_SIMULATOR_DYNAMODB', true),
|
|
14
|
+
s3: this.getEnvBool('AWS_LOCAL_SIMULATOR_S3', true),
|
|
15
|
+
sqs: this.getEnvBool('AWS_LOCAL_SIMULATOR_SQS', true),
|
|
16
|
+
sns: this.getEnvBool('AWS_LOCAL_SIMULATOR_SNS', false),
|
|
17
|
+
lambda: this.getEnvBool('AWS_LOCAL_SIMULATOR_LAMBDA', true),
|
|
18
|
+
apigateway: this.getEnvBool('AWS_LOCAL_SIMULATOR_APIGATEWAY', false),
|
|
19
|
+
eventbridge: this.getEnvBool('AWS_LOCAL_SIMULATOR_EVENTBRIDGE', false)
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Carrega portas
|
|
23
|
+
config.ports = {
|
|
24
|
+
dynamodb: this.getEnvInt('AWS_LOCAL_SIMULATOR_DYNAMODB_PORT', 8000),
|
|
25
|
+
s3: this.getEnvInt('AWS_LOCAL_SIMULATOR_S3_PORT', 4566),
|
|
26
|
+
sqs: this.getEnvInt('AWS_LOCAL_SIMULATOR_SQS_PORT', 9324),
|
|
27
|
+
lambda: this.getEnvInt('AWS_LOCAL_SIMULATOR_LAMBDA_PORT', 3001),
|
|
28
|
+
sns: this.getEnvInt('AWS_LOCAL_SIMULATOR_SNS_PORT', 9911),
|
|
29
|
+
apigateway: this.getEnvInt('AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT', 4567),
|
|
30
|
+
eventbridge: this.getEnvInt('AWS_LOCAL_SIMULATOR_EVENTBRIDGE_PORT', 4010)
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Carrega diretório de dados
|
|
34
|
+
config.dataDir = process.env.AWS_LOCAL_SIMULATOR_DATA || './.aws-local-simulator-data';
|
|
35
|
+
|
|
36
|
+
// Carrega nível de log
|
|
37
|
+
config.logLevel = process.env.AWS_LOCAL_SIMULATOR_LOG || 'info';
|
|
38
|
+
|
|
39
|
+
// Carrega CORS
|
|
40
|
+
config.cors = this.getEnvBool('AWS_LOCAL_SIMULATOR_CORS', true);
|
|
41
|
+
|
|
42
|
+
// Carrega auto-create
|
|
43
|
+
config.autoCreateTables = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_TABLES', true);
|
|
44
|
+
config.autoCreateBuckets = this.getEnvBool('AWS_LOCAL_SIMULATOR_AUTO_CREATE_BUCKETS', true);
|
|
45
|
+
|
|
46
|
+
logger.debug('Variáveis de ambiente carregadas:', config);
|
|
47
|
+
|
|
48
|
+
return config;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static getEnvBool(key, defaultValue) {
|
|
52
|
+
const value = process.env[key];
|
|
53
|
+
if (value === undefined) return defaultValue;
|
|
54
|
+
return value === 'true' || value === '1' || value === 'yes';
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static getEnvInt(key, defaultValue) {
|
|
58
|
+
const value = process.env[key];
|
|
59
|
+
if (value === undefined) return defaultValue;
|
|
60
|
+
const parsed = parseInt(value, 10);
|
|
61
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static getEnvString(key, defaultValue) {
|
|
65
|
+
return process.env[key] || defaultValue;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
69
|
module.exports = EnvLoader;
|