@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
@@ -1,203 +1,203 @@
1
- {
2
- "services": {
3
- "dynamodb": true,
4
- "s3": true,
5
- "sqs": true,
6
- "lambda": true,
7
- "sns": false,
8
- "eventbridge": false,
9
- "apigateway": true,
10
- "ecs": false
11
- },
12
- "ports": {
13
- "dynamodb": 8000,
14
- "s3": 4566,
15
- "sqs": 9324,
16
- "lambda": 3001,
17
- "sns": 9911,
18
- "eventbridge": 4010
19
- },
20
- "lambdas": [
21
- {
22
- "path": "/api/users",
23
- "handler": "./src/handlers/users.js",
24
- "type": "commonjs",
25
- "env": {
26
- "TABLE_NAME": "users-table",
27
- "BUCKET_NAME": "user-files"
28
- }
29
- },
30
- {
31
- "path": "/api/products",
32
- "handler": "./src/handlers/products.mjs",
33
- "type": "module",
34
- "env": {
35
- "TABLE_NAME": "products-table"
36
- }
37
- }
38
- ],
39
- "dynamodb": {
40
- "tables": [
41
- {
42
- "TableName": "users-table",
43
- "KeySchema": [{ "AttributeName": "userId", "KeyType": "HASH" }],
44
- "AttributeDefinitions": [{ "AttributeName": "userId", "AttributeType": "S" }],
45
- "ProvisionedThroughput": {
46
- "ReadCapacityUnits": 5,
47
- "WriteCapacityUnits": 5
48
- }
49
- }
50
- ]
51
- },
52
- "s3": {
53
- "buckets": ["users-files", "public-assets"]
54
- },
55
- "sqs": {
56
- "queues": [
57
- {
58
- "name": "notifications-queue",
59
- "lambdaPath": "/api/notifications",
60
- "batchSize": 10
61
- }
62
- ]
63
- },
64
- "apigateway": {
65
- "defaultCors": {
66
- "allowOrigins": ["http://localhost:3000"],
67
- "allowMethods": ["GET", "POST", "PUT", "DELETE"],
68
- "allowHeaders": ["Content-Type", "Authorization"],
69
- "maxAge": 300
70
- },
71
- "defaultThrottling": {
72
- "burstLimit": 50,
73
- "rateLimit": 10
74
- },
75
- "enableAccessLogging": true
76
- },
77
- "restApis": [
78
- {
79
- "name": "MyAPI",
80
- "description": "My REST API",
81
- "resources": [
82
- {
83
- "path": "/users",
84
- "methods": [
85
- {
86
- "httpMethod": "GET",
87
- "authorizationType": "NONE",
88
- "integration": {
89
- "type": "HTTP",
90
- "uri": "http://localhost:3001/users",
91
- "httpMethod": "GET"
92
- }
93
- },
94
- {
95
- "httpMethod": "POST",
96
- "authorizationType": "NONE",
97
- "integration": {
98
- "type": "AWS",
99
- "uri": "arn:aws:lambda:local:function:createUser"
100
- }
101
- }
102
- ]
103
- },
104
- {
105
- "path": "/users/{userId}",
106
- "methods": [
107
- {
108
- "httpMethod": "GET",
109
- "authorizationType": "NONE",
110
- "integration": {
111
- "type": "HTTP",
112
- "uri": "http://localhost:3001/users/{userId}",
113
- "httpMethod": "GET"
114
- }
115
- }
116
- ]
117
- }
118
- ],
119
- "stages": [
120
- {
121
- "stageName": "dev",
122
- "variables": {
123
- "ENVIRONMENT": "development"
124
- }
125
- },
126
- {
127
- "stageName": "prod",
128
- "variables": {
129
- "ENVIRONMENT": "production"
130
- }
131
- }
132
- ]
133
- }
134
- ],
135
- "apiKeys": [
136
- {
137
- "name": "MyAPIKey",
138
- "description": "Key for MyAPI",
139
- "enabled": true
140
- }
141
- ],
142
- "usagePlans": [
143
- {
144
- "name": "BasicPlan",
145
- "description": "Basic usage plan",
146
- "throttle": {
147
- "burstLimit": 100,
148
- "rateLimit": 10
149
- },
150
- "quota": {
151
- "limit": 10000,
152
- "period": "DAY"
153
- },
154
- "apiStages": [
155
- {
156
- "apiId": "api_123",
157
- "stage": "dev"
158
- }
159
- ]
160
- }
161
- ],
162
- "ecs": {
163
- "clusters": ["production", "staging", "development"],
164
- "defaultTaskCpu": 512,
165
- "defaultTaskMemory": 1024,
166
- "containerRuntime": "simulate"
167
- },
168
- "taskDefinitions": [
169
- {
170
- "family": "my-app",
171
- "containerDefinitions": [
172
- {
173
- "name": "web",
174
- "image": "nginx:alpine",
175
- "cpu": 256,
176
- "memory": 512,
177
- "essential": true,
178
- "portMappings": [
179
- {
180
- "containerPort": 80,
181
- "hostPort": 0,
182
- "protocol": "tcp"
183
- }
184
- ],
185
- "environment": [{ "name": "ENVIRONMENT", "value": "local" }]
186
- }
187
- ],
188
- "networkMode": "awsvpc",
189
- "cpu": "512",
190
- "memory": "1024"
191
- }
192
- ],
193
- "services-ecs": [
194
- {
195
- "name": "my-web-service",
196
- "cluster": "development",
197
- "taskDefinition": "my-app",
198
- "desiredCount": 2,
199
- "schedulingStrategy": "REPLICA"
200
- }
201
- ]
202
-
203
- }
1
+ {
2
+ "services": {
3
+ "dynamodb": true,
4
+ "s3": true,
5
+ "sqs": true,
6
+ "lambda": true,
7
+ "sns": false,
8
+ "eventbridge": false,
9
+ "apigateway": true,
10
+ "ecs": false
11
+ },
12
+ "ports": {
13
+ "dynamodb": 8000,
14
+ "s3": 4566,
15
+ "sqs": 9324,
16
+ "lambda": 3001,
17
+ "sns": 9911,
18
+ "eventbridge": 4010
19
+ },
20
+ "lambdas": [
21
+ {
22
+ "path": "/api/users",
23
+ "handler": "./src/handlers/users.js",
24
+ "type": "commonjs",
25
+ "env": {
26
+ "TABLE_NAME": "users-table",
27
+ "BUCKET_NAME": "user-files"
28
+ }
29
+ },
30
+ {
31
+ "path": "/api/products",
32
+ "handler": "./src/handlers/products.mjs",
33
+ "type": "module",
34
+ "env": {
35
+ "TABLE_NAME": "products-table"
36
+ }
37
+ }
38
+ ],
39
+ "dynamodb": {
40
+ "tables": [
41
+ {
42
+ "TableName": "users-table",
43
+ "KeySchema": [{ "AttributeName": "userId", "KeyType": "HASH" }],
44
+ "AttributeDefinitions": [{ "AttributeName": "userId", "AttributeType": "S" }],
45
+ "ProvisionedThroughput": {
46
+ "ReadCapacityUnits": 5,
47
+ "WriteCapacityUnits": 5
48
+ }
49
+ }
50
+ ]
51
+ },
52
+ "s3": {
53
+ "buckets": ["users-files", "public-assets"]
54
+ },
55
+ "sqs": {
56
+ "queues": [
57
+ {
58
+ "name": "notifications-queue",
59
+ "lambdaPath": "/api/notifications",
60
+ "batchSize": 10
61
+ }
62
+ ]
63
+ },
64
+ "apigateway": {
65
+ "defaultCors": {
66
+ "allowOrigins": ["http://localhost:3000"],
67
+ "allowMethods": ["GET", "POST", "PUT", "DELETE"],
68
+ "allowHeaders": ["Content-Type", "Authorization"],
69
+ "maxAge": 300
70
+ },
71
+ "defaultThrottling": {
72
+ "burstLimit": 50,
73
+ "rateLimit": 10
74
+ },
75
+ "enableAccessLogging": true
76
+ },
77
+ "restApis": [
78
+ {
79
+ "name": "MyAPI",
80
+ "description": "My REST API",
81
+ "resources": [
82
+ {
83
+ "path": "/users",
84
+ "methods": [
85
+ {
86
+ "httpMethod": "GET",
87
+ "authorizationType": "NONE",
88
+ "integration": {
89
+ "type": "HTTP",
90
+ "uri": "http://localhost:3001/users",
91
+ "httpMethod": "GET"
92
+ }
93
+ },
94
+ {
95
+ "httpMethod": "POST",
96
+ "authorizationType": "NONE",
97
+ "integration": {
98
+ "type": "AWS",
99
+ "uri": "arn:aws:lambda:local:function:createUser"
100
+ }
101
+ }
102
+ ]
103
+ },
104
+ {
105
+ "path": "/users/{userId}",
106
+ "methods": [
107
+ {
108
+ "httpMethod": "GET",
109
+ "authorizationType": "NONE",
110
+ "integration": {
111
+ "type": "HTTP",
112
+ "uri": "http://localhost:3001/users/{userId}",
113
+ "httpMethod": "GET"
114
+ }
115
+ }
116
+ ]
117
+ }
118
+ ],
119
+ "stages": [
120
+ {
121
+ "stageName": "dev",
122
+ "variables": {
123
+ "ENVIRONMENT": "development"
124
+ }
125
+ },
126
+ {
127
+ "stageName": "prod",
128
+ "variables": {
129
+ "ENVIRONMENT": "production"
130
+ }
131
+ }
132
+ ]
133
+ }
134
+ ],
135
+ "apiKeys": [
136
+ {
137
+ "name": "MyAPIKey",
138
+ "description": "Key for MyAPI",
139
+ "enabled": true
140
+ }
141
+ ],
142
+ "usagePlans": [
143
+ {
144
+ "name": "BasicPlan",
145
+ "description": "Basic usage plan",
146
+ "throttle": {
147
+ "burstLimit": 100,
148
+ "rateLimit": 10
149
+ },
150
+ "quota": {
151
+ "limit": 10000,
152
+ "period": "DAY"
153
+ },
154
+ "apiStages": [
155
+ {
156
+ "apiId": "api_123",
157
+ "stage": "dev"
158
+ }
159
+ ]
160
+ }
161
+ ],
162
+ "ecs": {
163
+ "clusters": ["production", "staging", "development"],
164
+ "defaultTaskCpu": 512,
165
+ "defaultTaskMemory": 1024,
166
+ "containerRuntime": "simulate"
167
+ },
168
+ "taskDefinitions": [
169
+ {
170
+ "family": "my-app",
171
+ "containerDefinitions": [
172
+ {
173
+ "name": "web",
174
+ "image": "nginx:alpine",
175
+ "cpu": 256,
176
+ "memory": 512,
177
+ "essential": true,
178
+ "portMappings": [
179
+ {
180
+ "containerPort": 80,
181
+ "hostPort": 0,
182
+ "protocol": "tcp"
183
+ }
184
+ ],
185
+ "environment": [{ "name": "ENVIRONMENT", "value": "local" }]
186
+ }
187
+ ],
188
+ "networkMode": "awsvpc",
189
+ "cpu": "512",
190
+ "memory": "1024"
191
+ }
192
+ ],
193
+ "services-ecs": [
194
+ {
195
+ "name": "my-web-service",
196
+ "cluster": "development",
197
+ "taskDefinition": "my-app",
198
+ "desiredCount": 2,
199
+ "schedulingStrategy": "REPLICA"
200
+ }
201
+ ]
202
+
203
+ }
@@ -1,92 +1,92 @@
1
- // src/utils/aws-config.js
2
-
3
- /**
4
- * Cria configuração para AWS SDK baseada no ambiente
5
- */
6
- function createAWSConfig(options = {}) {
7
- const isLocal = process.env.NODE_ENV === 'development' || process.env.IS_LOCAL === 'true';
8
-
9
- const config = {
10
- region: options.region || process.env.AWS_REGION || 'us-east-1',
11
- credentials: options.credentials || {
12
- accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
13
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
14
- }
15
- };
16
-
17
- if (isLocal || options.forceLocal) {
18
- config.endpoints = {
19
- dynamoDB: options.dynamoDBEndpoint || process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
20
- s3: options.s3Endpoint || process.env.S3_ENDPOINT || 'http://localhost:4566',
21
- sqs: options.sqsEndpoint || process.env.SQS_ENDPOINT || 'http://localhost:9324',
22
- lambda: options.lambdaEndpoint || process.env.LAMBDA_ENDPOINT || 'http://localhost:3001'
23
- };
24
- }
25
-
26
- return config;
27
- }
28
-
29
- /**
30
- * Cria cliente DynamoDB configurado
31
- */
32
- function createDynamoDBClient(options = {}) {
33
- const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
34
- const config = createAWSConfig(options);
35
-
36
- const clientConfig = {
37
- region: config.region,
38
- credentials: config.credentials
39
- };
40
-
41
- if (config.endpoints?.dynamoDB) {
42
- clientConfig.endpoint = config.endpoints.dynamoDB;
43
- }
44
-
45
- return new DynamoDBClient(clientConfig);
46
- }
47
-
48
- /**
49
- * Cria cliente S3 configurado
50
- */
51
- function createS3Client(options = {}) {
52
- const { S3Client } = require('@aws-sdk/client-s3');
53
- const config = createAWSConfig(options);
54
-
55
- const clientConfig = {
56
- region: config.region,
57
- credentials: config.credentials
58
- };
59
-
60
- if (config.endpoints?.s3) {
61
- clientConfig.endpoint = config.endpoints.s3;
62
- clientConfig.forcePathStyle = true; // Necessário para S3 local
63
- }
64
-
65
- return new S3Client(clientConfig);
66
- }
67
-
68
- /**
69
- * Cria cliente SQS configurado
70
- */
71
- function createSQSClient(options = {}) {
72
- const { SQSClient } = require('@aws-sdk/client-sqs');
73
- const config = createAWSConfig(options);
74
-
75
- const clientConfig = {
76
- region: config.region,
77
- credentials: config.credentials
78
- };
79
-
80
- if (config.endpoints?.sqs) {
81
- clientConfig.endpoint = config.endpoints.sqs;
82
- }
83
-
84
- return new SQSClient(clientConfig);
85
- }
86
-
87
- module.exports = {
88
- createAWSConfig,
89
- createDynamoDBClient,
90
- createS3Client,
91
- createSQSClient
1
+ // src/utils/aws-config.js
2
+
3
+ /**
4
+ * Cria configuração para AWS SDK baseada no ambiente
5
+ */
6
+ function createAWSConfig(options = {}) {
7
+ const isLocal = process.env.NODE_ENV === 'development' || process.env.IS_LOCAL === 'true';
8
+
9
+ const config = {
10
+ region: options.region || process.env.AWS_REGION || 'us-east-1',
11
+ credentials: options.credentials || {
12
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
13
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
14
+ }
15
+ };
16
+
17
+ if (isLocal || options.forceLocal) {
18
+ config.endpoints = {
19
+ dynamoDB: options.dynamoDBEndpoint || process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
20
+ s3: options.s3Endpoint || process.env.S3_ENDPOINT || 'http://localhost:4566',
21
+ sqs: options.sqsEndpoint || process.env.SQS_ENDPOINT || 'http://localhost:9324',
22
+ lambda: options.lambdaEndpoint || process.env.LAMBDA_ENDPOINT || 'http://localhost:3001'
23
+ };
24
+ }
25
+
26
+ return config;
27
+ }
28
+
29
+ /**
30
+ * Cria cliente DynamoDB configurado
31
+ */
32
+ function createDynamoDBClient(options = {}) {
33
+ const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
34
+ const config = createAWSConfig(options);
35
+
36
+ const clientConfig = {
37
+ region: config.region,
38
+ credentials: config.credentials
39
+ };
40
+
41
+ if (config.endpoints?.dynamoDB) {
42
+ clientConfig.endpoint = config.endpoints.dynamoDB;
43
+ }
44
+
45
+ return new DynamoDBClient(clientConfig);
46
+ }
47
+
48
+ /**
49
+ * Cria cliente S3 configurado
50
+ */
51
+ function createS3Client(options = {}) {
52
+ const { S3Client } = require('@aws-sdk/client-s3');
53
+ const config = createAWSConfig(options);
54
+
55
+ const clientConfig = {
56
+ region: config.region,
57
+ credentials: config.credentials
58
+ };
59
+
60
+ if (config.endpoints?.s3) {
61
+ clientConfig.endpoint = config.endpoints.s3;
62
+ clientConfig.forcePathStyle = true; // Necessário para S3 local
63
+ }
64
+
65
+ return new S3Client(clientConfig);
66
+ }
67
+
68
+ /**
69
+ * Cria cliente SQS configurado
70
+ */
71
+ function createSQSClient(options = {}) {
72
+ const { SQSClient } = require('@aws-sdk/client-sqs');
73
+ const config = createAWSConfig(options);
74
+
75
+ const clientConfig = {
76
+ region: config.region,
77
+ credentials: config.credentials
78
+ };
79
+
80
+ if (config.endpoints?.sqs) {
81
+ clientConfig.endpoint = config.endpoints.sqs;
82
+ }
83
+
84
+ return new SQSClient(clientConfig);
85
+ }
86
+
87
+ module.exports = {
88
+ createAWSConfig,
89
+ createDynamoDBClient,
90
+ createS3Client,
91
+ createSQSClient
92
92
  };