@gugananuvem/aws-local-simulator 1.0.22 → 1.0.26
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 +45 -0
- package/aws-config +154 -0
- package/package.json +30 -84
- package/src/config/default-config.js +15 -4
- package/src/server.js +257 -21
- package/src/services/apigateway/server.js +37 -0
- package/src/services/apigateway/simulator.js +148 -4
- package/src/services/cognito/server.js +8 -14
- package/src/services/cognito/simulator.js +63 -11
- package/src/services/dynamodb/simulator.js +159 -49
- package/src/services/kms/server.js +15 -1
- package/src/services/kms/simulator.js +48 -28
- package/src/services/lambda/server.js +24 -0
- package/src/services/lambda/simulator.js +136 -12
- package/src/services/parameter-store/simulator.js +1 -1
- package/src/services/s3/server.js +21 -0
- package/src/services/s3/simulator.js +4 -1
- package/src/services/secret-manager/server.js +2 -1
- package/src/services/secret-manager/simulator.js +21 -10
- package/src/services/sns/server.js +32 -5
- package/src/services/sqs/server.js +11 -0
- package/src/services/sqs/simulator.js +74 -6
package/README.md
CHANGED
|
@@ -186,6 +186,50 @@ npx aws-local-simulator reset
|
|
|
186
186
|
npx aws-local-simulator status
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
+
## 🖥️ Management API
|
|
190
|
+
|
|
191
|
+
O simulador expõe uma API de gerenciamento em tempo de execução na porta `9999` (configurável via `adminPort`). Ela permite habilitar e desabilitar serviços individualmente sem reiniciar o processo.
|
|
192
|
+
|
|
193
|
+
### Endpoints da Management API
|
|
194
|
+
|
|
195
|
+
| Método | Rota | Descrição |
|
|
196
|
+
|--------|------|-----------|
|
|
197
|
+
| GET | `/__admin/services` | Lista todos os 19 serviços com status |
|
|
198
|
+
| GET | `/__admin/services/:name` | Status de um serviço específico |
|
|
199
|
+
| POST | `/__admin/services/:name/enable` | Habilita um serviço parado |
|
|
200
|
+
| POST | `/__admin/services/:name/disable` | Desabilita um serviço em execução |
|
|
201
|
+
|
|
202
|
+
### Exemplos
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Listar todos os serviços
|
|
206
|
+
curl http://localhost:9999/__admin/services
|
|
207
|
+
|
|
208
|
+
# Habilitar DynamoDB
|
|
209
|
+
curl -X POST http://localhost:9999/__admin/services/dynamodb/enable
|
|
210
|
+
|
|
211
|
+
# Desabilitar SQS
|
|
212
|
+
curl -X POST http://localhost:9999/__admin/services/sqs/disable
|
|
213
|
+
|
|
214
|
+
# Status de um serviço
|
|
215
|
+
curl http://localhost:9999/__admin/services/lambda
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Configuração da porta admin
|
|
219
|
+
|
|
220
|
+
```json
|
|
221
|
+
{
|
|
222
|
+
"adminPort": 9999
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Ou via variável de ambiente:
|
|
227
|
+
```bash
|
|
228
|
+
AWS_LOCAL_SIMULATOR_ADMIN_PORT=9999 npx aws-local-simulator start
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
> A Management API nunca persiste alterações em disco — todo o estado é mantido em memória. Para uso em desenvolvimento local apenas.
|
|
232
|
+
|
|
189
233
|
## 🔌 Endpoints
|
|
190
234
|
|
|
191
235
|
| Serviço | Endpoint | Admin |
|
|
@@ -210,6 +254,7 @@ npx aws-local-simulator status
|
|
|
210
254
|
| CloudFormation | http://localhost:4580 | http://localhost:4580/__admin/stacks |
|
|
211
255
|
| Athena | http://localhost:4599 | http://localhost:4599/__admin/health |
|
|
212
256
|
| ECS | http://localhost:8080 | http://localhost:8080/__admin/clusters |
|
|
257
|
+
| Management API | http://localhost:9999 | http://localhost:9999/__admin/services |
|
|
213
258
|
|
|
214
259
|
## 🧪 Testando com AWS CLI
|
|
215
260
|
|
package/aws-config
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// lambda/layer/utils/aws-config.js
|
|
2
|
+
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
|
|
3
|
+
const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');
|
|
4
|
+
const { S3Client } = require('@aws-sdk/client-s3');
|
|
5
|
+
const { SQSClient } = require('@aws-sdk/client-sqs');
|
|
6
|
+
const { LambdaClient } = require('@aws-sdk/client-lambda');
|
|
7
|
+
const { CognitoIdentityProviderClient } = require("@aws-sdk/client-cognito-identity-provider");
|
|
8
|
+
|
|
9
|
+
// Detecta ambiente local
|
|
10
|
+
const isLocal = process.env.IS_LOCAL === 'true' ||
|
|
11
|
+
process.env.NODE_ENV === 'development' ||
|
|
12
|
+
process.env.AWS_SAM_LOCAL === 'true';
|
|
13
|
+
|
|
14
|
+
const isLocalS3 = process.env.IS_LOCAL_S3 === 'true'
|
|
15
|
+
const isLocalSQS = process.env.IS_LOCAL_SQS === 'true'
|
|
16
|
+
const isLocalDynamoDB = process.env.IS_LOCAL_DYNAMODB === 'true'
|
|
17
|
+
const isLocalLambda = process.env.IS_LOCAL_LAMBDA === 'true'
|
|
18
|
+
const isLocalCognito = process.env.IS_LOCAL_COGNITO === 'true'
|
|
19
|
+
|
|
20
|
+
// Endpoints locais (configuráveis via variáveis de ambiente)
|
|
21
|
+
const localEndpoints = {
|
|
22
|
+
dynamodb: process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
|
|
23
|
+
s3: process.env.S3_ENDPOINT || 'http://localhost:4566',
|
|
24
|
+
sqs: process.env.SQS_ENDPOINT || 'http://localhost:9324',
|
|
25
|
+
lambda: process.env.LAMBDA_ENDPOINT || 'http://localhost:3001',
|
|
26
|
+
cognito: process.env.LOCAL_COGNITO || 'http://localhost:9229'
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Credenciais para ambiente local (não são validadas)
|
|
30
|
+
const localCredentials = {
|
|
31
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
|
|
32
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local',
|
|
33
|
+
sessionToken: process.env.AWS_SESSION_TOKEN || undefined
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Configuração base para todos os clients
|
|
37
|
+
const baseConfig = {
|
|
38
|
+
region: process.env.AWS_REGION || 'us-east-1',
|
|
39
|
+
credentials: isLocal ? localCredentials : undefined
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// ============ DynamoDB Client ============
|
|
43
|
+
const dynamoDBClient = new DynamoDBClient({
|
|
44
|
+
...baseConfig,
|
|
45
|
+
endpoint: isLocalDynamoDB ? localEndpoints.dynamodb : undefined,
|
|
46
|
+
region: process.env.AWS_REGION || "us-east-1"
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const dynamoDBDocClient = DynamoDBDocumentClient.from(dynamoDBClient, {
|
|
50
|
+
marshallOptions: {
|
|
51
|
+
removeUndefinedValues: true,
|
|
52
|
+
convertEmptyValues: false
|
|
53
|
+
},
|
|
54
|
+
unmarshallOptions: {
|
|
55
|
+
wrapNumbers: false
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const cognitoClient = new CognitoIdentityProviderClient({
|
|
60
|
+
...baseConfig,
|
|
61
|
+
endpoint: isLocalCognito ? localEndpoints.cognito : undefined,
|
|
62
|
+
region: process.env.AWS_REGION || 'us-east-1'
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// ============ S3 Client ============
|
|
66
|
+
const s3Client = new S3Client({
|
|
67
|
+
...baseConfig,
|
|
68
|
+
endpoint: isLocalS3 ? localEndpoints.s3 : undefined,
|
|
69
|
+
forcePathStyle: true, // Necessário para S3 local (LocalStack, MinIO, etc)
|
|
70
|
+
// Para S3 real, não usar forcePathStyle
|
|
71
|
+
...(isLocalS3 ? {} : { forcePathStyle: false })
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// ============ SQS Client ============
|
|
75
|
+
const sqsClient = new SQSClient({
|
|
76
|
+
...baseConfig,
|
|
77
|
+
endpoint: isLocalSQS ? localEndpoints.sqs : undefined
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// ============ Lambda Client ============
|
|
81
|
+
const lambdaClient = new LambdaClient({
|
|
82
|
+
...baseConfig,
|
|
83
|
+
endpoint: isLocalLambda ? localEndpoints.lambda : undefined
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// Log de configuração (apenas em desenvolvimento)
|
|
87
|
+
if (isLocalDynamoDB || isLocalS3 || isLocalSQS || isLocalLambda) {
|
|
88
|
+
console.log('🔧 Ambiente LOCAL detectado:');
|
|
89
|
+
console.log(` DynamoDB: ${localEndpoints.dynamodb}`);
|
|
90
|
+
console.log(` S3: ${localEndpoints.s3} (forcePathStyle: true)`);
|
|
91
|
+
console.log(` SQS: ${localEndpoints.sqs}`);
|
|
92
|
+
console.log(` Lambda: ${localEndpoints.lambda}`);
|
|
93
|
+
console.log(` Region: ${baseConfig.region}`);
|
|
94
|
+
}
|
|
95
|
+
if (isLocalDynamoDB || isLocalS3 || isLocalSQS || isLocalLambda) {
|
|
96
|
+
console.log('🔧 Ambiente LOCAL detectado:');
|
|
97
|
+
console.log(` Region: ${baseConfig.region}`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (isLocalDynamoDB) {
|
|
101
|
+
console.log(` DynamoDB: ${localEndpoints.dynamodb}`);
|
|
102
|
+
}
|
|
103
|
+
if (isLocalS3) {
|
|
104
|
+
console.log(` S3: ${localEndpoints.s3} (forcePathStyle: true)`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isLocalSQS) {
|
|
108
|
+
console.log(` SQS: ${localEndpoints.sqs}`);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (isLocalLambda) {
|
|
112
|
+
console.log(` Lambda: ${localEndpoints.lambda}`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (isLocalCognito){
|
|
116
|
+
console.log(` Cognito: ${localEndpoints.cognito}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
module.exports = {
|
|
120
|
+
// Clients
|
|
121
|
+
dynamoDB: dynamoDBDocClient,
|
|
122
|
+
cognitoClient,
|
|
123
|
+
dynamoDBClient,
|
|
124
|
+
s3: s3Client,
|
|
125
|
+
sqs: sqsClient,
|
|
126
|
+
lambda: lambdaClient,
|
|
127
|
+
|
|
128
|
+
// Utilitários
|
|
129
|
+
isLocal,
|
|
130
|
+
localEndpoints,
|
|
131
|
+
|
|
132
|
+
// Configuração
|
|
133
|
+
config: {
|
|
134
|
+
region: baseConfig.region,
|
|
135
|
+
isLocal,
|
|
136
|
+
endpoints: localEndpoints
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// Função para criar clients customizados (útil para testes)
|
|
140
|
+
createS3Client: (customEndpoint) => {
|
|
141
|
+
return new S3Client({
|
|
142
|
+
...baseConfig,
|
|
143
|
+
endpoint: customEndpoint || localEndpoints.s3,
|
|
144
|
+
forcePathStyle: true
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
createDynamoDBClient: (customEndpoint) => {
|
|
149
|
+
return new DynamoDBClient({
|
|
150
|
+
...baseConfig,
|
|
151
|
+
endpoint: customEndpoint || localEndpoints.dynamodb
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
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.26",
|
|
4
4
|
"description": "Simulador local completo para serviços AWS",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -9,31 +9,30 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"start": "node bin/aws-local-simulator.js start"
|
|
11
11
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"detectOpenHandles": true
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@aws-sdk/client-api-gateway": "^3.0.0",
|
|
14
|
+
"@aws-sdk/client-cognito-identity-provider": "^3.0.0",
|
|
15
|
+
"@aws-sdk/client-dynamodb": "^3.0.0",
|
|
16
|
+
"@aws-sdk/client-ecs": "^3.0.0",
|
|
17
|
+
"@aws-sdk/client-lambda": "^3.0.0",
|
|
18
|
+
"@aws-sdk/client-s3": "^3.0.0",
|
|
19
|
+
"@aws-sdk/client-sqs": "^3.0.0",
|
|
20
|
+
"@aws-sdk/lib-dynamodb": "^3.0.0",
|
|
21
|
+
"child_process": "1.0.2",
|
|
22
|
+
"cors": "^2.8.5",
|
|
23
|
+
"crypto": "1.0.1",
|
|
24
|
+
"dotenv": "^16.3.1",
|
|
25
|
+
"express": "^4.18.2",
|
|
26
|
+
"fs": "0.0.1-security",
|
|
27
|
+
"glob": "10.5.0",
|
|
28
|
+
"http": "0.0.1-security",
|
|
29
|
+
"js-yaml": "4.1.1",
|
|
30
|
+
"jsonwebtoken": "^9.0.2",
|
|
31
|
+
"mkdirp": "^3.0.1",
|
|
32
|
+
"path": "0.12.7",
|
|
33
|
+
"url": "0.11.4",
|
|
34
|
+
"urlpattern-polyfill": "^10.0.0",
|
|
35
|
+
"uuid": "14.0.0"
|
|
37
36
|
},
|
|
38
37
|
"keywords": [
|
|
39
38
|
"aws",
|
|
@@ -43,21 +42,7 @@
|
|
|
43
42
|
"s3",
|
|
44
43
|
"sqs",
|
|
45
44
|
"lambda",
|
|
46
|
-
"cognito"
|
|
47
|
-
"apigateway",
|
|
48
|
-
"kms",
|
|
49
|
-
"config",
|
|
50
|
-
"parameter-store",
|
|
51
|
-
"secret-manager",
|
|
52
|
-
"cloudformation",
|
|
53
|
-
"eventbridge",
|
|
54
|
-
"sns",
|
|
55
|
-
"ecs",
|
|
56
|
-
"sts",
|
|
57
|
-
"cloudtrail",
|
|
58
|
-
"cloudwatch",
|
|
59
|
-
"development",
|
|
60
|
-
"testing"
|
|
45
|
+
"cognito"
|
|
61
46
|
],
|
|
62
47
|
"author": {
|
|
63
48
|
"name": "gugananuvem",
|
|
@@ -69,57 +54,18 @@
|
|
|
69
54
|
"url": "git+https://github.com/gugananuvem/aws-local-simulator.git"
|
|
70
55
|
},
|
|
71
56
|
"engines": {
|
|
72
|
-
"node": ">=
|
|
57
|
+
"node": ">=18.0.0"
|
|
73
58
|
},
|
|
74
59
|
"files": [
|
|
75
60
|
"src/",
|
|
76
61
|
"bin/",
|
|
77
62
|
"README.md",
|
|
78
|
-
"LICENSE"
|
|
63
|
+
"LICENSE",
|
|
64
|
+
"aws-config"
|
|
79
65
|
],
|
|
80
66
|
"publishConfig": {
|
|
81
67
|
"directory": "dist"
|
|
82
68
|
},
|
|
83
|
-
"
|
|
84
|
-
"cors": "^2.8.5",
|
|
85
|
-
"dotenv": "^16.3.1",
|
|
86
|
-
"express": "^4.18.2",
|
|
87
|
-
"glob": "^10.3.0",
|
|
88
|
-
"jsonwebtoken": "^9.0.2",
|
|
89
|
-
"mkdirp": "^3.0.1",
|
|
90
|
-
"urlpattern-polyfill": "^10.0.0",
|
|
91
|
-
"uuid": "^9.0.0"
|
|
92
|
-
},
|
|
93
|
-
"peerDependencies": {
|
|
94
|
-
"@aws-sdk/client-api-gateway": "^3.0.0",
|
|
95
|
-
"@aws-sdk/client-cognito-identity-provider": "^3.0.0",
|
|
96
|
-
"@aws-sdk/client-dynamodb": "^3.0.0",
|
|
97
|
-
"@aws-sdk/client-ecs": "^3.0.0",
|
|
98
|
-
"@aws-sdk/client-lambda": "^3.1032.0",
|
|
99
|
-
"@aws-sdk/client-s3": "^3.0.0",
|
|
100
|
-
"@aws-sdk/client-sqs": "^3.0.0",
|
|
101
|
-
"@aws-sdk/lib-dynamodb": "^3.0.0"
|
|
102
|
-
},
|
|
103
|
-
"peerDependenciesMeta": {
|
|
104
|
-
"@aws-sdk/client-dynamodb": {
|
|
105
|
-
"optional": true
|
|
106
|
-
},
|
|
107
|
-
"@aws-sdk/client-s3": {
|
|
108
|
-
"optional": true
|
|
109
|
-
},
|
|
110
|
-
"@aws-sdk/client-sqs": {
|
|
111
|
-
"optional": true
|
|
112
|
-
},
|
|
113
|
-
"@aws-sdk/client-cognito-identity-provider": {
|
|
114
|
-
"optional": true
|
|
115
|
-
},
|
|
116
|
-
"@aws-sdk/client-api-gateway": {
|
|
117
|
-
"optional": true
|
|
118
|
-
},
|
|
119
|
-
"@aws-sdk/client-ecs": {
|
|
120
|
-
"optional": true
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
"buildDate": "2026-04-22T18:03:41.660Z",
|
|
69
|
+
"buildDate": "2026-04-27T11:03:00.202Z",
|
|
124
70
|
"published": true
|
|
125
71
|
}
|
|
@@ -9,12 +9,16 @@ module.exports = {
|
|
|
9
9
|
s3: true,
|
|
10
10
|
sqs: true,
|
|
11
11
|
lambda: true,
|
|
12
|
-
sns:
|
|
13
|
-
eventbridge:
|
|
12
|
+
sns: true,
|
|
13
|
+
eventbridge: true,
|
|
14
14
|
ecs: false,
|
|
15
|
-
cognito:
|
|
16
|
-
apigateway:
|
|
15
|
+
cognito: true,
|
|
16
|
+
apigateway: true,
|
|
17
17
|
sts: true,
|
|
18
|
+
"secret-manager": true,
|
|
19
|
+
"parameter-store": true,
|
|
20
|
+
kms: true,
|
|
21
|
+
kinesis: true,
|
|
18
22
|
},
|
|
19
23
|
|
|
20
24
|
// Portas padrão
|
|
@@ -30,6 +34,10 @@ module.exports = {
|
|
|
30
34
|
apigateway: 4567,
|
|
31
35
|
sts: 9326,
|
|
32
36
|
athena: 4599,
|
|
37
|
+
secretManager: 4001,
|
|
38
|
+
parameterStore: 4002,
|
|
39
|
+
kms: 4000,
|
|
40
|
+
kinesis: 4568,
|
|
33
41
|
},
|
|
34
42
|
apigateway: {
|
|
35
43
|
defaultCors: {
|
|
@@ -65,4 +73,7 @@ module.exports = {
|
|
|
65
73
|
|
|
66
74
|
// Configurações adicionais
|
|
67
75
|
additional: {},
|
|
76
|
+
|
|
77
|
+
// Porta do servidor de administração (Management API)
|
|
78
|
+
adminPort: 9999,
|
|
68
79
|
};
|