@gugananuvem/aws-local-simulator 1.0.12 → 1.0.15

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.
Files changed (77) hide show
  1. package/README.md +594 -257
  2. package/bin/aws-local-simulator.js +63 -63
  3. package/package.json +21 -10
  4. package/src/config/config-loader.js +114 -114
  5. package/src/config/default-config.js +68 -67
  6. package/src/config/env-loader.js +68 -68
  7. package/src/index.js +146 -130
  8. package/src/index.mjs +123 -123
  9. package/src/server.js +227 -223
  10. package/src/services/apigateway/index.js +73 -68
  11. package/src/services/apigateway/server.js +507 -487
  12. package/src/services/apigateway/simulator.js +1261 -1251
  13. package/src/services/athena/index.js +75 -0
  14. package/src/services/athena/server.js +101 -0
  15. package/src/services/athena/simulador.js +998 -0
  16. package/src/services/athena/simulator.js +346 -0
  17. package/src/services/cloudformation/index.js +106 -0
  18. package/src/services/cloudformation/server.js +417 -0
  19. package/src/services/cloudformation/simulador.js +1045 -0
  20. package/src/services/cloudtrail/index.js +84 -0
  21. package/src/services/cloudtrail/server.js +235 -0
  22. package/src/services/cloudtrail/simulador.js +719 -0
  23. package/src/services/cloudwatch/index.js +84 -0
  24. package/src/services/cloudwatch/server.js +366 -0
  25. package/src/services/cloudwatch/simulador.js +1173 -0
  26. package/src/services/cognito/index.js +79 -65
  27. package/src/services/cognito/server.js +301 -279
  28. package/src/services/cognito/simulator.js +1655 -1115
  29. package/src/services/config/index.js +96 -0
  30. package/src/services/config/server.js +215 -0
  31. package/src/services/config/simulador.js +1260 -0
  32. package/src/services/dynamodb/index.js +74 -70
  33. package/src/services/dynamodb/server.js +125 -121
  34. package/src/services/dynamodb/simulator.js +630 -620
  35. package/src/services/ecs/index.js +65 -65
  36. package/src/services/ecs/server.js +235 -233
  37. package/src/services/ecs/simulator.js +844 -844
  38. package/src/services/eventbridge/index.js +89 -85
  39. package/src/services/eventbridge/server.js +209 -0
  40. package/src/services/eventbridge/simulator.js +684 -0
  41. package/src/services/index.js +45 -19
  42. package/src/services/kms/index.js +75 -0
  43. package/src/services/kms/server.js +67 -0
  44. package/src/services/kms/simulator.js +324 -0
  45. package/src/services/lambda/handler-loader.js +183 -183
  46. package/src/services/lambda/index.js +78 -73
  47. package/src/services/lambda/route-registry.js +274 -274
  48. package/src/services/lambda/server.js +145 -145
  49. package/src/services/lambda/simulator.js +199 -172
  50. package/src/services/parameter-store/index.js +80 -0
  51. package/src/services/parameter-store/server.js +50 -0
  52. package/src/services/parameter-store/simulator.js +201 -0
  53. package/src/services/s3/index.js +73 -69
  54. package/src/services/s3/server.js +329 -238
  55. package/src/services/s3/simulator.js +565 -740
  56. package/src/services/secret-manager/index.js +80 -0
  57. package/src/services/secret-manager/server.js +50 -0
  58. package/src/services/secret-manager/simulator.js +171 -0
  59. package/src/services/sns/index.js +89 -76
  60. package/src/services/sns/server.js +580 -0
  61. package/src/services/sns/simulator.js +1482 -0
  62. package/src/services/sqs/index.js +93 -95
  63. package/src/services/sqs/server.js +349 -345
  64. package/src/services/sqs/simulator.js +441 -441
  65. package/src/services/sts/index.js +37 -37
  66. package/src/services/sts/server.js +144 -142
  67. package/src/services/sts/simulator.js +69 -69
  68. package/src/services/xray/index.js +83 -0
  69. package/src/services/xray/server.js +308 -0
  70. package/src/services/xray/simulador.js +994 -0
  71. package/src/template/aws-config-template.js +87 -87
  72. package/src/template/aws-config-template.mjs +90 -90
  73. package/src/template/config-template.json +203 -203
  74. package/src/utils/aws-config.js +91 -91
  75. package/src/utils/cloudtrail-audit.js +129 -0
  76. package/src/utils/local-store.js +83 -67
  77. package/src/utils/logger.js +59 -59
package/README.md CHANGED
@@ -1,257 +1,594 @@
1
- # AWS Local Simulator
2
-
3
- [![npm version](https://badge.fury.io/js/aws-local-simulator.svg)](https://badge.fury.io/js/aws-local-simulator)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
- [![Node.js Version](https://img.shields.io/node/v/aws-local-simulator.svg)](https://nodejs.org)
6
-
7
- Simulador local completo para serviços AWS. Desenvolva e teste suas aplicações AWS localmente sem custos!
8
-
9
- ## 🚀 Serviços Suportados
10
-
11
- | Serviço | Status | Porta Padrão | Descrição |
12
- |---------|--------|--------------|-----------|
13
- | DynamoDB | ✅ | 8000 | Banco de dados NoSQL |
14
- | S3 | ✅ | 4566 | Armazenamento de objetos |
15
- | SQS | ✅ | 9324 | Filas de mensagens |
16
- | Lambda | ✅ | 3001 | Funções serverless (invocação por nome) |
17
- | Cognito | ✅ | 9229 | Autenticação e autorização |
18
- | API Gateway | ✅ | 4567 | APIs REST e HTTP |
19
- | STS | ✅ | 9326 | Credenciais temporárias (AssumeRole, GetCallerIdentity) |
20
- | ECS/Fargate | 🚧 | 8080 | Orquestração de containers (em desenvolvimento) |
21
- | SNS | 🚧 | 9911 | Notificações (em desenvolvimento) |
22
- | EventBridge | 🚧 | 4010 | Barramento de eventos (em desenvolvimento) |
23
-
24
- ## 📦 Instalação
25
-
26
- ```bash
27
- npm install --save-dev aws-local-simulator
28
- ```
29
-
30
- ## 🚀 Uso Rápido
31
-
32
- ### 1. Crie um arquivo de configuração `aws-local-simulator.json`:
33
-
34
- ```json
35
- {
36
- "services": {
37
- "dynamodb": true,
38
- "s3": true,
39
- "sqs": true,
40
- "lambda": true,
41
- "cognito": true,
42
- "apigateway": true,
43
- "sts": true
44
- },
45
- "lambdas": [
46
- {
47
- "name": "my-function",
48
- "handler": "./src/handlers/users.js",
49
- "env": {
50
- "TABLE_NAME": "users-table"
51
- }
52
- }
53
- ],
54
- "dynamodb": {
55
- "tables": [
56
- {
57
- "TableName": "users-table",
58
- "KeySchema": [{ "AttributeName": "id", "KeyType": "HASH" }],
59
- "AttributeDefinitions": [{ "AttributeName": "id", "AttributeType": "S" }]
60
- }
61
- ]
62
- },
63
- "s3": {
64
- "buckets": ["my-bucket"]
65
- },
66
- "sqs": {
67
- "queues": ["my-queue", "dead-letter-queue"]
68
- },
69
- "cognito": {
70
- "userPools": [
71
- {
72
- "PoolName": "my-user-pool",
73
- "AutoVerifiedAttributes": ["email"]
74
- }
75
- ]
76
- }
77
- }
78
- ```
79
-
80
- ### 2. Inicie o simulador:
81
-
82
- ```bash
83
- # Via CLI
84
- npx aws-local-simulator start
85
-
86
- # Ou via código
87
- const { AWSLocalSimulator } = require('aws-local-simulator');
88
- const simulator = new AWSLocalSimulator();
89
- await simulator.start();
90
- ```
91
-
92
- ### 3. Configure seu código para usar os serviços locais:
93
-
94
- ```javascript
95
- const { dynamoDB, s3, sqs, cognito } = require('aws-local-simulator/aws-config');
96
-
97
- await dynamoDB.send(new PutCommand({
98
- TableName: 'users-table',
99
- Item: { id: '123', name: 'John' }
100
- }));
101
- ```
102
-
103
- ## 🔧 Configuração por Variáveis de Ambiente
104
-
105
- | Variável | Descrição | Padrão |
106
- |---------|----------|-------|
107
- | AWS_LOCAL_SIMULATOR_DYNAMODB | Habilita DynamoDB | true |
108
- | AWS_LOCAL_SIMULATOR_S3 | Habilita S3 | true |
109
- | AWS_LOCAL_SIMULATOR_SQS | Habilita SQS | true |
110
- | AWS_LOCAL_SIMULATOR_LAMBDA | Habilita Lambda | true |
111
- | AWS_LOCAL_SIMULATOR_COGNITO | Habilita Cognito | false |
112
- | AWS_LOCAL_SIMULATOR_APIGATEWAY | Habilita API Gateway | false |
113
- | AWS_LOCAL_SIMULATOR_STS | Habilita STS | true |
114
- | AWS_LOCAL_SIMULATOR_ECS | Habilita ECS/Fargate | false |
115
- | AWS_LOCAL_SIMULATOR_DYNAMODB_PORT | Porta DynamoDB | 8000 |
116
- | AWS_LOCAL_SIMULATOR_S3_PORT | Porta S3 | 4566 |
117
- | AWS_LOCAL_SIMULATOR_SQS_PORT | Porta SQS | 9324 |
118
- | AWS_LOCAL_SIMULATOR_LAMBDA_PORT | Porta Lambda | 3001 |
119
- | AWS_LOCAL_SIMULATOR_COGNITO_PORT | Porta Cognito | 9229 |
120
- | AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT | Porta API Gateway | 4567 |
121
- | AWS_LOCAL_SIMULATOR_STS_PORT | Porta STS | 9326 |
122
- | AWS_LOCAL_SIMULATOR_ECS_PORT | Porta ECS | 8080 |
123
- | AWS_LOCAL_SIMULATOR_DATA | Diretório de dados | ./aws-local-simulator-data |
124
- | AWS_LOCAL_SIMULATOR_LOG | Nível de log | info |
125
-
126
- ## 📝 Comandos CLI
127
-
128
- ```bash
129
- # Iniciar simulador
130
- npx aws-local-simulator start [configPath]
131
-
132
- # Parar simulador
133
- npx aws-local-simulator stop
134
-
135
- # Reiniciar
136
- npx aws-local-simulator restart
137
-
138
- # Resetar dados
139
- npx aws-local-simulator reset
140
-
141
- # Status
142
- npx aws-local-simulator status
143
- ```
144
-
145
- ## 🔌 Endpoints
146
-
147
- | Serviço | Endpoint | Admin |
148
- |---------|----------|-------|
149
- | DynamoDB | http://localhost:8000 | http://localhost:8000/__admin/tables |
150
- | S3 | http://localhost:4566 | http://localhost:4566/__admin/buckets |
151
- | SQS | http://localhost:9324 | http://localhost:9324/__admin/queues |
152
- | Lambda | http://localhost:3001 | http://localhost:3001/__admin/functions |
153
- | Cognito | http://localhost:9229 | http://localhost:9229/__admin/userpools |
154
- | API Gateway | http://localhost:4567 | http://localhost:4567/__admin/apis |
155
- | STS | http://localhost:9326 | |
156
- | ECS | http://localhost:8080 | http://localhost:8080/__admin/clusters |
157
-
158
- ## 🧪 Testando com AWS CLI
159
-
160
- ```bash
161
- # DynamoDB
162
- aws dynamodb list-tables --endpoint-url http://localhost:8000
163
-
164
- # S3
165
- aws s3 ls --endpoint-url http://localhost:4566
166
-
167
- # SQS
168
- aws sqs list-queues --endpoint-url http://localhost:9324
169
-
170
- # Lambda invocar por nome (não por path HTTP)
171
- aws lambda invoke \
172
- --function-name my-function \
173
- --payload '{"key":"value"}' \
174
- --endpoint-url http://localhost:3001 \
175
- output.json
176
-
177
- # Cognito
178
- aws cognito-idp list-user-pools --max-results 10 --endpoint-url http://localhost:9229
179
-
180
- # STS
181
- aws sts get-caller-identity --endpoint-url http://localhost:9326
182
- aws sts assume-role \
183
- --role-arn "arn:aws:iam::123456789012:role/my-role" \
184
- --role-session-name "my-session" \
185
- --endpoint-url http://localhost:9326
186
-
187
- # API Gateway
188
- aws apigateway get-rest-apis --endpoint-url http://localhost:4567
189
- ```
190
-
191
- ## ⚙️ Configuração de Lambdas
192
-
193
- Lambdas são registradas por **nome** e invocadas via API de invocação (igual à AWS real). O roteamento HTTP é feito pelo API Gateway.
194
-
195
- ```json
196
- {
197
- "lambdas": [
198
- {
199
- "name": "my-function",
200
- "handler": "./src/handlers/my-function.js",
201
- "env": {
202
- "TABLE_NAME": "users-table",
203
- "BUCKET_NAME": "my-bucket"
204
- }
205
- }
206
- ]
207
- }
208
- ```
209
-
210
- O handler deve exportar uma função padrão:
211
-
212
- ```javascript
213
- exports.handler = async (event, context) => {
214
- return {
215
- statusCode: 200,
216
- body: JSON.stringify({ message: 'Hello from Lambda!' })
217
- };
218
- };
219
- ```
220
-
221
- ## 📁 Estrutura de Dados
222
-
223
- Os dados são persistidos em:
224
-
225
- ```text
226
- .aws-local-simulator-data/
227
- ├── dynamodb/
228
- ├── s3/
229
- ├── sqs/
230
- ├── cognito/
231
- ├── apigateway/
232
- └── ecs/
233
- ```
234
-
235
- ## 🐛 Debug
236
-
237
- ```bash
238
- AWS_LOCAL_SIMULATOR_LOG=verboso npx aws-local-simulator start
239
- ```
240
-
241
- ## 🤝 Contribuindo
242
-
243
- 1. Fork o projeto
244
- 2. Crie sua feature branch (`git checkout -b feature/AmazingFeature`)
245
- 3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
246
- 4. Push para a branch (`git push origin feature/AmazingFeature`)
247
- 5. Abra um Pull Request
248
-
249
- ## 📄 Licença
250
-
251
- MIT © Luiz Gustavo Ribeiro
252
-
253
- ## ⚠️ Limitações
254
-
255
- - SNS e EventBridge em desenvolvimento
256
- - WebSocket APIs em desenvolvimento
257
- - Para uso em desenvolvimento e testes apenas
1
+ # AWS Local Simulator
2
+
3
+ [![npm version](https://badge.fury.io/js/aws-local-simulator.svg)](https://badge.fury.io/js/aws-local-simulator)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/node/v/aws-local-simulator.svg)](https://nodejs.org)
6
+
7
+ Simulador local completo para serviços AWS. Desenvolva e teste suas aplicações AWS localmente sem custos!
8
+
9
+ ## 🚀 Serviços Suportados
10
+
11
+ | Serviço | Status | Porta Padrão | Descrição |
12
+ |---------|--------|--------------|-----------|
13
+ | DynamoDB | ✅ | 8000 | Banco de dados NoSQL |
14
+ | S3 | ✅ | 4566 | Armazenamento de objetos |
15
+ | SQS | ✅ | 9324 | Filas de mensagens |
16
+ | Lambda | ✅ | 3001 | Funções serverless |
17
+ | Cognito | ✅ | 9229 | Autenticação e autorização |
18
+ | API Gateway | ✅ | 4567 | APIs REST e HTTP |
19
+ | STS | ✅ | 9326 | Credenciais temporárias |
20
+ | SNS | | 9911 | Notificações pub/sub |
21
+ | EventBridge | | 4010 | Barramento de eventos |
22
+ | KMS | | 4000 | Gerenciamento de chaves |
23
+ | Secrets Manager | ✅ | 4001 | Gerenciamento de segredos |
24
+ | Parameter Store | ✅ | 4002 | Armazenamento de parâmetros |
25
+ | CloudWatch | ✅ | 4011 | Logs, métricas e alarmes |
26
+ | CloudTrail | ✅ | 4012 | Auditoria de API calls |
27
+ | AWS Config | ✅ | 4013 | Conformidade e configuração |
28
+ | CloudFormation | ✅ | 4580 | Infraestrutura como código |
29
+ | Athena | ✅ | 4599 | Consultas SQL em dados no S3 |
30
+ | X-Ray | ✅ | 4015 | Rastreamento distribuído |
31
+ | ECS/Fargate | 🚧 | 8080 | Orquestração de containers (em desenvolvimento) |
32
+
33
+ ## 📦 Instalação
34
+
35
+ ```bash
36
+ npm install --save-dev aws-local-simulator
37
+ ```
38
+
39
+ ## 🚀 Uso Rápido
40
+
41
+ ### 1. Crie um arquivo de configuração `aws-local-simulator.json`:
42
+
43
+ ```json
44
+ {
45
+ "services": {
46
+ "dynamodb": true,
47
+ "s3": true,
48
+ "sqs": true,
49
+ "lambda": true,
50
+ "cognito": true,
51
+ "apigateway": true,
52
+ "sts": true,
53
+ "sns": true,
54
+ "eventbridge": true,
55
+ "kms": true,
56
+ "secret-manager": true,
57
+ "parameter-store": true,
58
+ "cloudwatch": true,
59
+ "cloudtrail": true,
60
+ "cloudformation": true,
61
+ "xray": true,
62
+ "config": true,
63
+ "athena": true
64
+ },
65
+ "lambdas": [
66
+ {
67
+ "name": "my-function",
68
+ "handler": "./src/handlers/users.js",
69
+ "env": {
70
+ "TABLE_NAME": "users-table"
71
+ }
72
+ }
73
+ ],
74
+ "dynamodb": {
75
+ "tables": [
76
+ {
77
+ "TableName": "users-table",
78
+ "KeySchema": [{ "AttributeName": "id", "KeyType": "HASH" }],
79
+ "AttributeDefinitions": [{ "AttributeName": "id", "AttributeType": "S" }]
80
+ }
81
+ ]
82
+ },
83
+ "s3": {
84
+ "buckets": [
85
+ { "name": "my-bucket", "region": "us-east-1" }
86
+ ]
87
+ },
88
+ "sqs": {
89
+ "queues": ["my-queue", "dead-letter-queue"]
90
+ },
91
+ "cognito": {
92
+ "userPools": [
93
+ {
94
+ "PoolName": "my-user-pool",
95
+ "AutoVerifiedAttributes": ["email"]
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### 2. Inicie o simulador:
103
+
104
+ ```bash
105
+ # Via CLI
106
+ npx aws-local-simulator start
107
+
108
+ # Ou via código
109
+ const { AWSLocalSimulator } = require('aws-local-simulator');
110
+ const simulator = new AWSLocalSimulator();
111
+ await simulator.start();
112
+ ```
113
+
114
+ ### 3. Configure seu código para usar os serviços locais:
115
+
116
+ ```javascript
117
+ const { dynamoDB, s3, sqs, cognito } = require('aws-local-simulator/aws-config');
118
+
119
+ await dynamoDB.send(new PutCommand({
120
+ TableName: 'users-table',
121
+ Item: { id: '123', name: 'John' }
122
+ }));
123
+ ```
124
+
125
+ ## 🔧 Configuração por Variáveis de Ambiente
126
+
127
+ | Variável | Descrição | Padrão |
128
+ |---------|----------|-------|
129
+ | AWS_LOCAL_SIMULATOR_DYNAMODB | Habilita DynamoDB | true |
130
+ | AWS_LOCAL_SIMULATOR_S3 | Habilita S3 | true |
131
+ | AWS_LOCAL_SIMULATOR_SQS | Habilita SQS | true |
132
+ | AWS_LOCAL_SIMULATOR_LAMBDA | Habilita Lambda | true |
133
+ | AWS_LOCAL_SIMULATOR_COGNITO | Habilita Cognito | false |
134
+ | AWS_LOCAL_SIMULATOR_APIGATEWAY | Habilita API Gateway | false |
135
+ | AWS_LOCAL_SIMULATOR_STS | Habilita STS | true |
136
+ | AWS_LOCAL_SIMULATOR_SNS | Habilita SNS | false |
137
+ | AWS_LOCAL_SIMULATOR_EVENTBRIDGE | Habilita EventBridge | false |
138
+ | AWS_LOCAL_SIMULATOR_KMS | Habilita KMS | false |
139
+ | AWS_LOCAL_SIMULATOR_SECRET_MANAGER | Habilita Secrets Manager | false |
140
+ | AWS_LOCAL_SIMULATOR_PARAMETER_STORE | Habilita Parameter Store | false |
141
+ | AWS_LOCAL_SIMULATOR_CLOUDWATCH | Habilita CloudWatch | false |
142
+ | AWS_LOCAL_SIMULATOR_CLOUDTRAIL | Habilita CloudTrail | false |
143
+ | AWS_LOCAL_SIMULATOR_CLOUDFORMATION | Habilita CloudFormation | false |
144
+ | AWS_LOCAL_SIMULATOR_ATHENA | Habilita Athena | false |
145
+ | AWS_LOCAL_SIMULATOR_XRAY | Habilita X-Ray | false |
146
+ | AWS_LOCAL_SIMULATOR_CONFIG | Habilita AWS Config | false |
147
+ | AWS_LOCAL_SIMULATOR_ECS | Habilita ECS/Fargate | false |
148
+ | AWS_LOCAL_SIMULATOR_DYNAMODB_PORT | Porta DynamoDB | 8000 |
149
+ | AWS_LOCAL_SIMULATOR_S3_PORT | Porta S3 | 4566 |
150
+ | AWS_LOCAL_SIMULATOR_SQS_PORT | Porta SQS | 9324 |
151
+ | AWS_LOCAL_SIMULATOR_LAMBDA_PORT | Porta Lambda | 3001 |
152
+ | AWS_LOCAL_SIMULATOR_COGNITO_PORT | Porta Cognito | 9229 |
153
+ | AWS_LOCAL_SIMULATOR_APIGATEWAY_PORT | Porta API Gateway | 4567 |
154
+ | AWS_LOCAL_SIMULATOR_STS_PORT | Porta STS | 9326 |
155
+ | AWS_LOCAL_SIMULATOR_SNS_PORT | Porta SNS | 9911 |
156
+ | AWS_LOCAL_SIMULATOR_EVENTBRIDGE_PORT | Porta EventBridge | 4010 |
157
+ | AWS_LOCAL_SIMULATOR_KMS_PORT | Porta KMS | 4000 |
158
+ | AWS_LOCAL_SIMULATOR_SECRET_MANAGER_PORT | Porta Secrets Manager | 4001 |
159
+ | AWS_LOCAL_SIMULATOR_PARAMETER_STORE_PORT | Porta Parameter Store | 4002 |
160
+ | AWS_LOCAL_SIMULATOR_CLOUDWATCH_PORT | Porta CloudWatch | 4011 |
161
+ | AWS_LOCAL_SIMULATOR_CLOUDTRAIL_PORT | Porta CloudTrail | 4012 |
162
+ | AWS_LOCAL_SIMULATOR_CONFIG_PORT | Porta AWS Config | 4013 |
163
+ | AWS_LOCAL_SIMULATOR_XRAY_PORT | Porta X-Ray | 4015 |
164
+ | AWS_LOCAL_SIMULATOR_CLOUDFORMATION_PORT | Porta CloudFormation | 4580 |
165
+ | AWS_LOCAL_SIMULATOR_ATHENA_PORT | Porta Athena | 4599 |
166
+ | AWS_LOCAL_SIMULATOR_ECS_PORT | Porta ECS | 8080 |
167
+ | AWS_LOCAL_SIMULATOR_DATA | Diretório de dados | ./aws-local-simulator-data |
168
+ | AWS_LOCAL_SIMULATOR_LOG | Nível de log | info |
169
+
170
+ ## 📝 Comandos CLI
171
+
172
+ ```bash
173
+ # Iniciar simulador
174
+ npx aws-local-simulator start [configPath]
175
+
176
+ # Parar simulador
177
+ npx aws-local-simulator stop
178
+
179
+ # Reiniciar
180
+ npx aws-local-simulator restart
181
+
182
+ # Resetar dados
183
+ npx aws-local-simulator reset
184
+
185
+ # Status
186
+ npx aws-local-simulator status
187
+ ```
188
+
189
+ ## 🔌 Endpoints
190
+
191
+ | Serviço | Endpoint | Admin |
192
+ |---------|----------|-------|
193
+ | DynamoDB | http://localhost:8000 | http://localhost:8000/__admin/tables |
194
+ | S3 | http://localhost:4566 | http://localhost:4566/__admin/buckets |
195
+ | S3 Website | http://localhost:4566/website/{bucket}/ | — |
196
+ | SQS | http://localhost:9324 | http://localhost:9324/__admin/queues |
197
+ | Lambda | http://localhost:3001 | http://localhost:3001/__admin/functions |
198
+ | Cognito | http://localhost:9229 | http://localhost:9229/__admin/userpools |
199
+ | API Gateway | http://localhost:4567 | http://localhost:4567/__admin/apis |
200
+ | STS | http://localhost:9326 | — |
201
+ | SNS | http://localhost:9911 | http://localhost:9911/__admin/health |
202
+ | EventBridge | http://localhost:4010 | — |
203
+ | KMS | http://localhost:4000 | — |
204
+ | Secrets Manager | http://localhost:4001 | — |
205
+ | Parameter Store | http://localhost:4002 | — |
206
+ | CloudWatch | http://localhost:4011 | — |
207
+ | CloudTrail | http://localhost:4012 | — |
208
+ | AWS Config | http://localhost:4013 | — |
209
+ | X-Ray | http://localhost:4015 | — |
210
+ | CloudFormation | http://localhost:4580 | http://localhost:4580/__admin/stacks |
211
+ | Athena | http://localhost:4599 | http://localhost:4599/__admin/health |
212
+ | ECS | http://localhost:8080 | http://localhost:8080/__admin/clusters |
213
+
214
+ ## 🧪 Testando com AWS CLI
215
+
216
+ ```bash
217
+ # DynamoDB
218
+ aws dynamodb list-tables --endpoint-url http://localhost:8000
219
+
220
+ # S3
221
+ aws s3 ls --endpoint-url http://localhost:4566
222
+
223
+ # SQS
224
+ aws sqs list-queues --endpoint-url http://localhost:9324
225
+
226
+ # Lambda
227
+ aws lambda invoke \
228
+ --function-name my-function \
229
+ --payload '{"key":"value"}' \
230
+ --endpoint-url http://localhost:3001 \
231
+ output.json
232
+
233
+ # Cognito
234
+ aws cognito-idp list-user-pools --max-results 10 --endpoint-url http://localhost:9229
235
+
236
+ # Cognito cadastrar um usuario pelo adminstrador
237
+ aws cognito-idp admin-create-user \
238
+ --user-pool-id us-east-xxxx\
239
+ --username usuario@email.com \
240
+ --user-attributes \
241
+ Name=email,Value=usuario@email.com \
242
+ Name=email_verified,Value=false \
243
+ Name=name,Value="nome usuario" \
244
+ Name=custom:role,Value="user" \
245
+ temporary-password "Teste@123456" \
246
+ --message-action SUPPRESS \
247
+ --endpoint-url http://localhost:9229
248
+
249
+ # Cognito excluir um usuario
250
+ aws cognito-idp admin-delete-user \
251
+ --user-pool-id us-east-xxxx \
252
+ --username usuario@email.com
253
+ --endpoint-url http://localhost:9229
254
+
255
+ # Cognito Registrar usuário
256
+ aws cognito-idp sign-up \
257
+ --client-id $CLIENT_ID \
258
+ --username usuario@email.com \
259
+ --password "Teste@123456" \
260
+ --user-attributes Name=email,Value=usuario@email.com Name=name,Value="nome usuario"
261
+ --endpoint-url http://localhost:9229
262
+
263
+ # 2. Confirmar usuário administrativamente
264
+ aws cognito-idp admin-confirm-sign-up \
265
+ --user-pool-id us-east-xxxx \
266
+ --username usuario@email.com
267
+ --endpoint-url http://localhost:9229
268
+
269
+ # O código chega no e-mail do usuário. Algo como: "Your confirmation code is 123456"
270
+ aws cognito-idp confirm-sign-up \
271
+ --client-id 3n4b5urk1ft4fl3mg5e62d9ado \
272
+ --username usuario@email.com \
273
+ --confirmation-code 123456
274
+ --endpoint-url http://localhost:9229
275
+
276
+ # STS
277
+ aws sts get-caller-identity --endpoint-url http://localhost:9326
278
+ aws sts assume-role \
279
+ --role-arn "arn:aws:iam::123456789012:role/my-role" \
280
+ --role-session-name "my-session" \
281
+ --endpoint-url http://localhost:9326
282
+
283
+ # SNS
284
+ aws sns list-topics --endpoint-url http://localhost:9911
285
+
286
+ # EventBridge
287
+ aws events list-event-buses --endpoint-url http://localhost:4010
288
+
289
+ # KMS
290
+ aws kms list-keys --endpoint-url http://localhost:4000
291
+
292
+ # Secrets Manager
293
+ aws secretsmanager list-secrets --endpoint-url http://localhost:4001
294
+
295
+ # Criar secret
296
+ aws secretsmanager create-secret \
297
+ --name "local/app/db-credentials" \
298
+ --description "Credenciais do banco" \
299
+ --secret-string '{"username":"admin","password":"secret123"}' \
300
+ --endpoint-url http://localhost:4001
301
+
302
+ # Ler secret
303
+ aws secretsmanager get-secret-value \
304
+ --secret-id "local/app/db-credentials" \
305
+ --endpoint-url http://localhost:4001
306
+
307
+ # Parameter Store
308
+ aws ssm describe-parameters --endpoint-url http://localhost:4002
309
+
310
+ # Criar parâmetro String
311
+ aws ssm put-parameter \
312
+ --name "/local/app/config" \
313
+ --value '{"timeout":30,"maxRetries":3}' \
314
+ --type String \
315
+ --endpoint-url http://localhost:4002
316
+
317
+ # Criar parâmetro SecureString
318
+ aws ssm put-parameter \
319
+ --name "/local/app/api-key" \
320
+ --value "my-secret-api-key" \
321
+ --type SecureString \
322
+ --endpoint-url http://localhost:4002
323
+
324
+ # Ler parâmetro
325
+ aws ssm get-parameter \
326
+ --name "/local/app/config" \
327
+ --endpoint-url http://localhost:4002
328
+
329
+ # CloudWatch
330
+ aws cloudwatch list-metrics --endpoint-url http://localhost:4011
331
+ aws logs describe-log-groups --endpoint-url http://localhost:4011
332
+
333
+ # CloudTrail
334
+ aws cloudtrail describe-trails --endpoint-url http://localhost:4012
335
+
336
+ # CloudFormation
337
+ aws cloudformation list-stacks --endpoint-url http://localhost:4580
338
+
339
+ # X-Ray
340
+ aws xray get-trace-summaries \
341
+ --start-time $(date -d '1 hour ago' +%s) \
342
+ --end-time $(date +%s) \
343
+ --endpoint-url http://localhost:4015
344
+
345
+ # AWS Config
346
+ aws configservice describe-configuration-recorders --endpoint-url http://localhost:4013
347
+
348
+ # API Gateway
349
+ aws apigateway get-rest-apis --endpoint-url http://localhost:4567
350
+
351
+ # Cloudformation
352
+ aws cloudformation create-stack \
353
+ --stack-name test-stack \
354
+ --template-body file://templates/test-stack.yaml \
355
+ --parameters \
356
+ ParameterKey=Environment,ParameterValue=local \
357
+ ParameterKey=BucketName,ParameterValue=meu-bucket \
358
+ ParameterKey=QueueName,ParameterValue=minha-fila \
359
+ ParameterKey=TableName,ParameterValue=minha-tabela \
360
+ --endpoint-url http://localhost:4580
361
+
362
+ # Ver Cloudformation resultado
363
+ aws cloudformation describe-stacks \
364
+ --stack-name test-stack \
365
+ --endpoint-url http://localhost:4580
366
+
367
+ # Athena
368
+ # Criar workgroup
369
+ aws athena create-work-group \
370
+ --name my-workgroup \
371
+ --configuration ResultConfiguration={OutputLocation=s3://meu-bucket/athena-results/} \
372
+ --endpoint-url http://localhost:4599
373
+
374
+ # Listar workgroups
375
+ aws athena list-work-groups --endpoint-url http://localhost:4599
376
+
377
+ # Executar query
378
+ aws athena start-query-execution \
379
+ --query-string "SELECT * FROM my_table LIMIT 10" \
380
+ --query-execution-context Database=default \
381
+ --result-configuration OutputLocation=s3://meu-bucket/athena-results/ \
382
+ --endpoint-url http://localhost:4599
383
+
384
+ # Verificar status da query
385
+ aws athena get-query-execution \
386
+ --query-execution-id <id-retornado> \
387
+ --endpoint-url http://localhost:4599
388
+
389
+ # Buscar resultados
390
+ aws athena get-query-results \
391
+ --query-execution-id <id-retornado> \
392
+ --endpoint-url http://localhost:4599
393
+
394
+ # Criar named query
395
+ aws athena create-named-query \
396
+ --name "my-saved-query" \
397
+ --database default \
398
+ --query-string "SELECT id, value FROM my_table WHERE status = 'active'" \
399
+ --endpoint-url http://localhost:4599
400
+
401
+ # Listar named queries
402
+ aws athena list-named-queries --endpoint-url http://localhost:4599
403
+ ```
404
+
405
+ ## ⚙️ Configuração S3
406
+
407
+ ### Buckets simples
408
+
409
+ ```json
410
+ {
411
+ "s3": {
412
+ "buckets": [
413
+ "my-bucket"
414
+ ]
415
+ }
416
+ }
417
+ ```
418
+
419
+ ### Buckets com região e website estático
420
+
421
+ ```json
422
+ {
423
+ "s3": {
424
+ "buckets": [
425
+ { "name": "my-bucket", "region": "us-east-1" },
426
+ {
427
+ "name": "my-site-bucket",
428
+ "region": "us-east-1",
429
+ "websiteConfiguration": {
430
+ "IndexDocument": { "Suffix": "index.html" },
431
+ "ErrorDocument": { "Key": "error.html" }
432
+ }
433
+ }
434
+ ]
435
+ }
436
+ }
437
+ ```
438
+
439
+ Quando `websiteConfiguration` está presente, o bucket serve arquivos estáticos.
440
+
441
+ ### URL do website estático
442
+
443
+ ```
444
+ http://localhost:4566/website/{bucket-name}/
445
+ http://localhost:4566/website/{bucket-name}/caminho/pagina.html
446
+ ```
447
+
448
+ Exemplos:
449
+ ```
450
+ http://localhost:4566/website/my-site-bucket/ → serve index.html
451
+ http://localhost:4566/website/my-site-bucket/about.html → serve about.html
452
+ http://localhost:4566/website/my-site-bucket/app/ → serve app/index.html
453
+ ```
454
+
455
+ ### Gerenciar website config via AWS CLI
456
+
457
+ ```bash
458
+ # Habilitar website em um bucket existente
459
+ aws s3api put-bucket-website \
460
+ --bucket my-site-bucket \
461
+ --website-configuration '{"IndexDocument":{"Suffix":"index.html"},"ErrorDocument":{"Key":"error.html"}}' \
462
+ --endpoint-url http://localhost:4566
463
+
464
+ # Ver configuração de website
465
+ aws s3api get-bucket-website \
466
+ --bucket my-site-bucket \
467
+ --endpoint-url http://localhost:4566
468
+
469
+ # Remover website
470
+ aws s3api delete-bucket-website \
471
+ --bucket my-site-bucket \
472
+ --endpoint-url http://localhost:4566
473
+ ```
474
+
475
+ ## ⚙️ Configuração de Lambdas
476
+
477
+ Lambdas são registradas por **nome** e invocadas via API de invocação (igual à AWS real). O roteamento HTTP é feito pelo API Gateway.
478
+
479
+ ```json
480
+ {
481
+ "lambdas": [
482
+ {
483
+ "name": "my-user-function",
484
+ "handler": "./src/handlers/my-user-function.js",
485
+ "env": {
486
+ "TABLE_NAME": "users-table",
487
+ "BUCKET_NAME": "my-bucket"
488
+ }
489
+ }
490
+ ]
491
+ }
492
+ ```
493
+
494
+ ## ⚙️ Configuração API GATEWAY
495
+
496
+ O valor do **lambdaName** deve igual ao nome Lambda que está registrada com o valor **name**. Ex: "my-user-function".
497
+
498
+ ```json
499
+ {
500
+ "apigateway": {
501
+ "apis": [
502
+ {
503
+ "name": "Users API",
504
+ "description": "API para gerenciamento de usuários",
505
+ "endpoints": [
506
+ {
507
+ "path": "/user",
508
+ "method": "GET",
509
+ "lambdaName": "my-user-function",
510
+ "integrationType": "lambda"
511
+ },
512
+ {
513
+ "path": "/user",
514
+ "method": "POST",
515
+ "lambdaName": "my-user-function",
516
+ "integrationType": "lambda"
517
+ },
518
+ {
519
+ "path": "/user/{id}",
520
+ "method": "GET",
521
+ "lambdaName": "my-user-function",
522
+ "integrationType": "lambda"
523
+ },
524
+ {
525
+ "path": "/user/{id}",
526
+ "method": "DELETE",
527
+ "lambdaName": "my-user-function",
528
+ "integrationType": "lambda"
529
+ }
530
+ ]
531
+ }
532
+ ]
533
+ },
534
+
535
+ }
536
+ ```
537
+
538
+ O handler deve exportar uma função padrão:
539
+
540
+ ```javascript
541
+ exports.handler = async (event, context) => {
542
+ return {
543
+ statusCode: 200,
544
+ body: JSON.stringify({ message: 'Hello from Lambda!' })
545
+ };
546
+ };
547
+ ```
548
+
549
+ ## 📁 Estrutura de Dados
550
+
551
+ Os dados são persistidos em:
552
+
553
+ ```text
554
+ .aws-local-simulator-data/
555
+ ├── dynamodb/
556
+ ├── s3/
557
+ ├── sqs/
558
+ ├── cognito/
559
+ ├── apigateway/
560
+ ├── ecs/
561
+ ├── kms/
562
+ ├── secret-manager/
563
+ ├── parameter-store/
564
+ ├── cloudwatch/
565
+ ├── cloudtrail/
566
+ ├── cloudformation/
567
+ ├── athena/
568
+ ├── xray/
569
+ └── config/
570
+ ```
571
+
572
+ ## 🐛 Debug
573
+
574
+ ```bash
575
+ AWS_LOCAL_SIMULATOR_LOG=verbose npx aws-local-simulator start
576
+ ```
577
+
578
+ ## 🤝 Contribuindo
579
+
580
+ 1. Fork o projeto
581
+ 2. Crie sua feature branch (`git checkout -b feature/AmazingFeature`)
582
+ 3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
583
+ 4. Push para a branch (`git push origin feature/AmazingFeature`)
584
+ 5. Abra um Pull Request
585
+
586
+ ## 📄 Licença
587
+
588
+ MIT © Luiz Gustavo Ribeiro
589
+
590
+ ## ⚠️ Limitações
591
+
592
+ - ECS/Fargate em desenvolvimento
593
+ - WebSocket APIs em desenvolvimento
594
+ - Para uso em desenvolvimento e testes apenas