@gugananuvem/aws-local-simulator 1.0.10 → 1.0.12

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 (44) hide show
  1. package/README.md +257 -193
  2. package/bin/aws-local-simulator.js +62 -62
  3. package/package.json +2 -2
  4. package/src/config/config-loader.js +114 -112
  5. package/src/config/default-config.js +67 -65
  6. package/src/config/env-loader.js +68 -68
  7. package/src/index.js +130 -130
  8. package/src/index.mjs +123 -123
  9. package/src/server.js +223 -222
  10. package/src/services/apigateway/index.js +68 -66
  11. package/src/services/apigateway/server.js +487 -434
  12. package/src/services/apigateway/simulator.js +1251 -1251
  13. package/src/services/cognito/index.js +65 -65
  14. package/src/services/cognito/server.js +279 -228
  15. package/src/services/cognito/simulator.js +1114 -847
  16. package/src/services/dynamodb/index.js +70 -70
  17. package/src/services/dynamodb/server.js +121 -121
  18. package/src/services/dynamodb/simulator.js +620 -614
  19. package/src/services/ecs/index.js +65 -65
  20. package/src/services/ecs/server.js +233 -233
  21. package/src/services/ecs/simulator.js +844 -844
  22. package/src/services/eventbridge/index.js +84 -84
  23. package/src/services/index.js +18 -18
  24. package/src/services/lambda/handler-loader.js +183 -172
  25. package/src/services/lambda/index.js +73 -72
  26. package/src/services/lambda/route-registry.js +274 -274
  27. package/src/services/lambda/server.js +145 -152
  28. package/src/services/lambda/simulator.js +172 -285
  29. package/src/services/s3/index.js +69 -69
  30. package/src/services/s3/server.js +238 -238
  31. package/src/services/s3/simulator.js +740 -740
  32. package/src/services/sns/index.js +75 -75
  33. package/src/services/sqs/index.js +95 -95
  34. package/src/services/sqs/server.js +345 -273
  35. package/src/services/sqs/simulator.js +441 -660
  36. package/src/services/sts/index.js +37 -0
  37. package/src/services/sts/server.js +142 -0
  38. package/src/services/sts/simulator.js +69 -0
  39. package/src/template/aws-config-template.js +87 -87
  40. package/src/template/aws-config-template.mjs +90 -90
  41. package/src/template/config-template.json +203 -203
  42. package/src/utils/aws-config.js +91 -91
  43. package/src/utils/local-store.js +67 -67
  44. package/src/utils/logger.js +59 -59
@@ -0,0 +1,37 @@
1
+ const STSServer = require('./server');
2
+ const logger = require('../../utils/logger');
3
+
4
+ class STSService {
5
+ constructor(config) {
6
+ this.config = config;
7
+ this.name = 'sts';
8
+ this.port = config.ports.sts || 9326;
9
+ this.server = null;
10
+ this.isRunning = false;
11
+ }
12
+
13
+ async initialize() {
14
+ this.server = new STSServer(this.port, this.config);
15
+ await this.server.initialize();
16
+ }
17
+
18
+ async start() {
19
+ if (this.isRunning) return;
20
+ await this.server.start();
21
+ this.isRunning = true;
22
+ }
23
+
24
+ async stop() {
25
+ if (!this.isRunning) return;
26
+ await this.server.stop();
27
+ this.isRunning = false;
28
+ }
29
+
30
+ async reset() {}
31
+
32
+ getStatus() {
33
+ return { running: this.isRunning, port: this.port, endpoint: `http://localhost:${this.port}` };
34
+ }
35
+ }
36
+
37
+ module.exports = STSService;
@@ -0,0 +1,142 @@
1
+ const express = require('express');
2
+ const crypto = require('crypto');
3
+ const STSSimulator = require('./simulator');
4
+ const logger = require('../../utils/logger');
5
+
6
+ class STSServer {
7
+ constructor(port, config) {
8
+ this.port = port;
9
+ this.config = config;
10
+ this.app = express();
11
+ this.simulator = new STSSimulator(config);
12
+ this.server = null;
13
+ this.setupMiddlewares();
14
+ }
15
+
16
+ setupMiddlewares() {
17
+ this.app.use(express.raw({ type: '*/*', limit: '10mb' }));
18
+ this.app.use((req, res, next) => {
19
+ if (req.body && Buffer.isBuffer(req.body)) {
20
+ const str = req.body.toString('utf8');
21
+ const ct = req.headers['content-type'] || '';
22
+ if (ct.includes('application/x-www-form-urlencoded')) {
23
+ req.body = Object.fromEntries(new URLSearchParams(str));
24
+ } else {
25
+ try { req.body = JSON.parse(str); } catch (e) { req.body = {}; }
26
+ }
27
+ } else { req.body = req.body || {}; }
28
+ next();
29
+ });
30
+ }
31
+
32
+ async initialize() {
33
+ await this.simulator.initialize();
34
+ this.setupRoutes();
35
+ logger.debug('STS Server inicializado');
36
+ }
37
+
38
+ setupRoutes() {
39
+ this.app.post('/', (req, res) => {
40
+ // STS uses query protocol: Action in body or query string
41
+ const action = req.query.Action || req.body.Action ||
42
+ (req.headers['x-amz-target'] && req.headers['x-amz-target'].split('.')[1]);
43
+
44
+ logger.debug(`STS action: ${action}`);
45
+
46
+ try {
47
+ const result = this.handleAction(action, req.body);
48
+ const xml = this.generateXmlResponse(action, result);
49
+ res.set('Content-Type', 'text/xml');
50
+ res.send(xml);
51
+ } catch (err) {
52
+ logger.error('STS Error:', err.message);
53
+ res.status(400).send(this.simulator.generateErrorResponse('InvalidAction', err.message));
54
+ }
55
+ });
56
+ }
57
+
58
+ handleAction(action, params) {
59
+ switch (action) {
60
+ case 'AssumeRole': return this.simulator.assumeRole(params);
61
+ case 'GetCallerIdentity': return this.simulator.getCallerIdentity(params);
62
+ case 'GetSessionToken': return this.simulator.getSessionToken(params);
63
+ case 'AssumeRoleWithWebIdentity': return this.simulator.assumeRoleWithWebIdentity(params);
64
+ case 'AssumeRoleWithSAML': return this.simulator.assumeRoleWithSAML(params);
65
+ default: throw new Error(`Unsupported STS action: ${action}`);
66
+ }
67
+ }
68
+
69
+ generateXmlResponse(action, result) {
70
+ const requestId = crypto.randomUUID();
71
+ switch (action) {
72
+ case 'AssumeRole':
73
+ case 'AssumeRoleWithWebIdentity':
74
+ case 'AssumeRoleWithSAML':
75
+ return `<?xml version="1.0" encoding="UTF-8"?>
76
+ <${action}Response xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
77
+ <${action}Result>
78
+ <Credentials>
79
+ <AccessKeyId>${result.Credentials.AccessKeyId}</AccessKeyId>
80
+ <SecretAccessKey>${result.Credentials.SecretAccessKey}</SecretAccessKey>
81
+ <SessionToken>${result.Credentials.SessionToken}</SessionToken>
82
+ <Expiration>${result.Credentials.Expiration}</Expiration>
83
+ </Credentials>
84
+ <AssumedRoleUser>
85
+ <AssumedRoleId>${result.AssumedRoleUser.AssumedRoleId}</AssumedRoleId>
86
+ <Arn>${result.AssumedRoleUser.Arn}</Arn>
87
+ </AssumedRoleUser>
88
+ </${action}Result>
89
+ <ResponseMetadata><RequestId>${requestId}</RequestId></ResponseMetadata>
90
+ </${action}Response>`;
91
+
92
+ case 'GetCallerIdentity':
93
+ return `<?xml version="1.0" encoding="UTF-8"?>
94
+ <GetCallerIdentityResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
95
+ <GetCallerIdentityResult>
96
+ <UserId>${result.UserId}</UserId>
97
+ <Account>${result.Account}</Account>
98
+ <Arn>${result.Arn}</Arn>
99
+ </GetCallerIdentityResult>
100
+ <ResponseMetadata><RequestId>${requestId}</RequestId></ResponseMetadata>
101
+ </GetCallerIdentityResponse>`;
102
+
103
+ case 'GetSessionToken':
104
+ return `<?xml version="1.0" encoding="UTF-8"?>
105
+ <GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
106
+ <GetSessionTokenResult>
107
+ <Credentials>
108
+ <AccessKeyId>${result.Credentials.AccessKeyId}</AccessKeyId>
109
+ <SecretAccessKey>${result.Credentials.SecretAccessKey}</SecretAccessKey>
110
+ <SessionToken>${result.Credentials.SessionToken}</SessionToken>
111
+ <Expiration>${result.Credentials.Expiration}</Expiration>
112
+ </Credentials>
113
+ </GetSessionTokenResult>
114
+ <ResponseMetadata><RequestId>${requestId}</RequestId></ResponseMetadata>
115
+ </GetSessionTokenResponse>`;
116
+
117
+ default: return '';
118
+ }
119
+ }
120
+
121
+ start() {
122
+ return new Promise((resolve) => {
123
+ this.server = this.app.listen(this.port, () => {
124
+ logger.info(`🔑 STS rodando em http://localhost:${this.port}`);
125
+ resolve();
126
+ });
127
+ });
128
+ }
129
+
130
+ stop() {
131
+ return new Promise((resolve) => {
132
+ if (this.server) this.server.close(() => resolve());
133
+ else resolve();
134
+ });
135
+ }
136
+
137
+ getStatus() {
138
+ return { running: !!this.server, port: this.port, endpoint: `http://localhost:${this.port}` };
139
+ }
140
+ }
141
+
142
+ module.exports = STSServer;
@@ -0,0 +1,69 @@
1
+ const crypto = require('crypto');
2
+ const logger = require('../../utils/logger');
3
+
4
+ class STSSimulator {
5
+ constructor(config) {
6
+ this.config = config;
7
+ this.assumedRoles = new Map();
8
+ }
9
+
10
+ async initialize() {
11
+ logger.debug('Inicializando STS Simulator...');
12
+ }
13
+
14
+ assumeRole(params = {}) {
15
+ const { RoleArn, RoleSessionName, DurationSeconds = 3600 } = params;
16
+ if (!RoleArn) throw new Error('RoleArn is required');
17
+ if (!RoleSessionName) throw new Error('RoleSessionName is required');
18
+
19
+ const accessKeyId = `ASIA${crypto.randomBytes(8).toString('hex').toUpperCase()}`;
20
+ const secretKey = crypto.randomBytes(20).toString('hex');
21
+ const sessionToken = crypto.randomBytes(64).toString('base64');
22
+ const expiration = new Date(Date.now() + DurationSeconds * 1000).toISOString();
23
+ const assumedRoleId = `AROA${crypto.randomBytes(8).toString('hex').toUpperCase()}:${RoleSessionName}`;
24
+
25
+ return {
26
+ Credentials: { AccessKeyId: accessKeyId, SecretAccessKey: secretKey, SessionToken: sessionToken, Expiration: expiration },
27
+ AssumedRoleUser: { AssumedRoleId: assumedRoleId, Arn: `${RoleArn}/${RoleSessionName}` },
28
+ PackedPolicySize: null
29
+ };
30
+ }
31
+
32
+ getCallerIdentity(params = {}) {
33
+ return {
34
+ UserId: 'AKIAIOSFODNN7EXAMPLE',
35
+ Account: '123456789012',
36
+ Arn: 'arn:aws:iam::123456789012:user/local-simulator'
37
+ };
38
+ }
39
+
40
+ getSessionToken(params = {}) {
41
+ const { DurationSeconds = 3600 } = params;
42
+ return {
43
+ Credentials: {
44
+ AccessKeyId: `ASIA${crypto.randomBytes(8).toString('hex').toUpperCase()}`,
45
+ SecretAccessKey: crypto.randomBytes(20).toString('hex'),
46
+ SessionToken: crypto.randomBytes(64).toString('base64'),
47
+ Expiration: new Date(Date.now() + DurationSeconds * 1000).toISOString()
48
+ }
49
+ };
50
+ }
51
+
52
+ assumeRoleWithWebIdentity(params = {}) {
53
+ return this.assumeRole({ ...params, RoleSessionName: params.RoleSessionName || 'web-identity-session' });
54
+ }
55
+
56
+ assumeRoleWithSAML(params = {}) {
57
+ return this.assumeRole({ ...params, RoleSessionName: params.RoleSessionName || 'saml-session' });
58
+ }
59
+
60
+ generateErrorResponse(code, message) {
61
+ return `<?xml version="1.0" encoding="UTF-8"?>
62
+ <ErrorResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
63
+ <Error><Code>${code}</Code><Message>${message}</Message></Error>
64
+ <RequestId>${crypto.randomUUID()}</RequestId>
65
+ </ErrorResponse>`;
66
+ }
67
+ }
68
+
69
+ module.exports = STSSimulator;
@@ -1,88 +1,88 @@
1
- /**
2
- * AWS SDK v3 Configuration for Local Development
3
- * Gerado pelo AWS Local Simulator
4
- */
5
-
6
- const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
7
- const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');
8
- const { S3Client } = require('@aws-sdk/client-s3');
9
- const { SQSClient } = require('@aws-sdk/client-sqs');
10
- const { SNSClient } = require('@aws-sdk/client-sns');
11
- const { EventBridgeClient } = require('@aws-sdk/client-eventbridge');
12
-
13
- // Configurações de ambiente
14
- const isLocal = process.env.IS_LOCAL === 'true' || process.env.NODE_ENV === 'development';
15
-
16
- // Endpoints locais (configuráveis via variáveis de ambiente)
17
- const endpoints = {
18
- dynamodb: process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
19
- s3: process.env.S3_ENDPOINT || 'http://localhost:4566',
20
- sqs: process.env.SQS_ENDPOINT || 'http://localhost:9324',
21
- sns: process.env.SNS_ENDPOINT || 'http://localhost:9911',
22
- eventbridge: process.env.EVENTBRIDGE_ENDPOINT || 'http://localhost:4010'
23
- };
24
-
25
- // Credenciais locais
26
- const localCredentials = {
27
- accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
28
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
29
- };
30
-
31
- const baseConfig = {
32
- region: process.env.AWS_REGION || 'us-east-1',
33
- credentials: isLocal ? localCredentials : undefined
34
- };
35
-
36
- // DynamoDB Client
37
- const dynamoDBClient = new DynamoDBClient({
38
- ...baseConfig,
39
- endpoint: isLocal ? endpoints.dynamodb : undefined
40
- });
41
-
42
- const dynamoDB = DynamoDBDocumentClient.from(dynamoDBClient);
43
-
44
- // S3 Client
45
- const s3 = new S3Client({
46
- ...baseConfig,
47
- endpoint: isLocal ? endpoints.s3 : undefined,
48
- forcePathStyle: isLocal
49
- });
50
-
51
- // SQS Client
52
- const sqs = new SQSClient({
53
- ...baseConfig,
54
- endpoint: isLocal ? endpoints.sqs : undefined
55
- });
56
-
57
- // SNS Client
58
- const sns = new SNSClient({
59
- ...baseConfig,
60
- endpoint: isLocal ? endpoints.sns : undefined
61
- });
62
-
63
- // EventBridge Client
64
- const eventbridge = new EventBridgeClient({
65
- ...baseConfig,
66
- endpoint: isLocal ? endpoints.eventbridge : undefined
67
- });
68
-
69
- module.exports = {
70
- // Clients
71
- dynamoDB,
72
- dynamoDBClient,
73
- s3,
74
- sqs,
75
- sns,
76
- eventbridge,
77
-
78
- // Utilitários
79
- isLocal,
80
- endpoints,
81
-
82
- // Configuração
83
- config: {
84
- region: baseConfig.region,
85
- isLocal,
86
- endpoints
87
- }
1
+ /**
2
+ * AWS SDK v3 Configuration for Local Development
3
+ * Gerado pelo AWS Local Simulator
4
+ */
5
+
6
+ const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
7
+ const { DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');
8
+ const { S3Client } = require('@aws-sdk/client-s3');
9
+ const { SQSClient } = require('@aws-sdk/client-sqs');
10
+ const { SNSClient } = require('@aws-sdk/client-sns');
11
+ const { EventBridgeClient } = require('@aws-sdk/client-eventbridge');
12
+
13
+ // Configurações de ambiente
14
+ const isLocal = process.env.IS_LOCAL === 'true' || process.env.NODE_ENV === 'development';
15
+
16
+ // Endpoints locais (configuráveis via variáveis de ambiente)
17
+ const endpoints = {
18
+ dynamodb: process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
19
+ s3: process.env.S3_ENDPOINT || 'http://localhost:4566',
20
+ sqs: process.env.SQS_ENDPOINT || 'http://localhost:9324',
21
+ sns: process.env.SNS_ENDPOINT || 'http://localhost:9911',
22
+ eventbridge: process.env.EVENTBRIDGE_ENDPOINT || 'http://localhost:4010'
23
+ };
24
+
25
+ // Credenciais locais
26
+ const localCredentials = {
27
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
28
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
29
+ };
30
+
31
+ const baseConfig = {
32
+ region: process.env.AWS_REGION || 'us-east-1',
33
+ credentials: isLocal ? localCredentials : undefined
34
+ };
35
+
36
+ // DynamoDB Client
37
+ const dynamoDBClient = new DynamoDBClient({
38
+ ...baseConfig,
39
+ endpoint: isLocal ? endpoints.dynamodb : undefined
40
+ });
41
+
42
+ const dynamoDB = DynamoDBDocumentClient.from(dynamoDBClient);
43
+
44
+ // S3 Client
45
+ const s3 = new S3Client({
46
+ ...baseConfig,
47
+ endpoint: isLocal ? endpoints.s3 : undefined,
48
+ forcePathStyle: isLocal
49
+ });
50
+
51
+ // SQS Client
52
+ const sqs = new SQSClient({
53
+ ...baseConfig,
54
+ endpoint: isLocal ? endpoints.sqs : undefined
55
+ });
56
+
57
+ // SNS Client
58
+ const sns = new SNSClient({
59
+ ...baseConfig,
60
+ endpoint: isLocal ? endpoints.sns : undefined
61
+ });
62
+
63
+ // EventBridge Client
64
+ const eventbridge = new EventBridgeClient({
65
+ ...baseConfig,
66
+ endpoint: isLocal ? endpoints.eventbridge : undefined
67
+ });
68
+
69
+ module.exports = {
70
+ // Clients
71
+ dynamoDB,
72
+ dynamoDBClient,
73
+ s3,
74
+ sqs,
75
+ sns,
76
+ eventbridge,
77
+
78
+ // Utilitários
79
+ isLocal,
80
+ endpoints,
81
+
82
+ // Configuração
83
+ config: {
84
+ region: baseConfig.region,
85
+ isLocal,
86
+ endpoints
87
+ }
88
88
  };
@@ -1,91 +1,91 @@
1
- /**
2
- * AWS SDK v3 Configuration for Local Development (ES Module)
3
- * Gerado pelo AWS Local Simulator
4
- */
5
-
6
- import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
7
- import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
8
- import { S3Client } from '@aws-sdk/client-s3';
9
- import { SQSClient } from '@aws-sdk/client-sqs';
10
- import { SNSClient } from '@aws-sdk/client-sns';
11
- import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
12
-
13
- // Configurações de ambiente
14
- const isLocal = process.env.IS_LOCAL === 'true' || process.env.NODE_ENV === 'development';
15
-
16
- // Endpoints locais
17
- const endpoints = {
18
- dynamodb: process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
19
- s3: process.env.S3_ENDPOINT || 'http://localhost:4566',
20
- sqs: process.env.SQS_ENDPOINT || 'http://localhost:9324',
21
- sns: process.env.SNS_ENDPOINT || 'http://localhost:9911',
22
- eventbridge: process.env.EVENTBRIDGE_ENDPOINT || 'http://localhost:4010'
23
- };
24
-
25
- // Credenciais locais
26
- const localCredentials = {
27
- accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
28
- secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
29
- };
30
-
31
- const baseConfig = {
32
- region: process.env.AWS_REGION || 'us-east-1',
33
- credentials: isLocal ? localCredentials : undefined
34
- };
35
-
36
- // DynamoDB Client
37
- const dynamoDBClient = new DynamoDBClient({
38
- ...baseConfig,
39
- endpoint: isLocal ? endpoints.dynamodb : undefined
40
- });
41
-
42
- const dynamoDB = DynamoDBDocumentClient.from(dynamoDBClient);
43
-
44
- // S3 Client
45
- const s3 = new S3Client({
46
- ...baseConfig,
47
- endpoint: isLocal ? endpoints.s3 : undefined,
48
- forcePathStyle: isLocal
49
- });
50
-
51
- // SQS Client
52
- const sqs = new SQSClient({
53
- ...baseConfig,
54
- endpoint: isLocal ? endpoints.sqs : undefined
55
- });
56
-
57
- // SNS Client
58
- const sns = new SNSClient({
59
- ...baseConfig,
60
- endpoint: isLocal ? endpoints.sns : undefined
61
- });
62
-
63
- // EventBridge Client
64
- const eventbridge = new EventBridgeClient({
65
- ...baseConfig,
66
- endpoint: isLocal ? endpoints.eventbridge : undefined
67
- });
68
-
69
- export {
70
- dynamoDB,
71
- dynamoDBClient,
72
- s3,
73
- sqs,
74
- sns,
75
- eventbridge,
76
- isLocal,
77
- endpoints,
78
- baseConfig as config
79
- };
80
-
81
- export default {
82
- dynamoDB,
83
- dynamoDBClient,
84
- s3,
85
- sqs,
86
- sns,
87
- eventbridge,
88
- isLocal,
89
- endpoints,
90
- config: baseConfig
1
+ /**
2
+ * AWS SDK v3 Configuration for Local Development (ES Module)
3
+ * Gerado pelo AWS Local Simulator
4
+ */
5
+
6
+ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
7
+ import { DynamoDBDocumentClient } from '@aws-sdk/lib-dynamodb';
8
+ import { S3Client } from '@aws-sdk/client-s3';
9
+ import { SQSClient } from '@aws-sdk/client-sqs';
10
+ import { SNSClient } from '@aws-sdk/client-sns';
11
+ import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
12
+
13
+ // Configurações de ambiente
14
+ const isLocal = process.env.IS_LOCAL === 'true' || process.env.NODE_ENV === 'development';
15
+
16
+ // Endpoints locais
17
+ const endpoints = {
18
+ dynamodb: process.env.DYNAMODB_ENDPOINT || 'http://localhost:8000',
19
+ s3: process.env.S3_ENDPOINT || 'http://localhost:4566',
20
+ sqs: process.env.SQS_ENDPOINT || 'http://localhost:9324',
21
+ sns: process.env.SNS_ENDPOINT || 'http://localhost:9911',
22
+ eventbridge: process.env.EVENTBRIDGE_ENDPOINT || 'http://localhost:4010'
23
+ };
24
+
25
+ // Credenciais locais
26
+ const localCredentials = {
27
+ accessKeyId: process.env.AWS_ACCESS_KEY_ID || 'local',
28
+ secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY || 'local'
29
+ };
30
+
31
+ const baseConfig = {
32
+ region: process.env.AWS_REGION || 'us-east-1',
33
+ credentials: isLocal ? localCredentials : undefined
34
+ };
35
+
36
+ // DynamoDB Client
37
+ const dynamoDBClient = new DynamoDBClient({
38
+ ...baseConfig,
39
+ endpoint: isLocal ? endpoints.dynamodb : undefined
40
+ });
41
+
42
+ const dynamoDB = DynamoDBDocumentClient.from(dynamoDBClient);
43
+
44
+ // S3 Client
45
+ const s3 = new S3Client({
46
+ ...baseConfig,
47
+ endpoint: isLocal ? endpoints.s3 : undefined,
48
+ forcePathStyle: isLocal
49
+ });
50
+
51
+ // SQS Client
52
+ const sqs = new SQSClient({
53
+ ...baseConfig,
54
+ endpoint: isLocal ? endpoints.sqs : undefined
55
+ });
56
+
57
+ // SNS Client
58
+ const sns = new SNSClient({
59
+ ...baseConfig,
60
+ endpoint: isLocal ? endpoints.sns : undefined
61
+ });
62
+
63
+ // EventBridge Client
64
+ const eventbridge = new EventBridgeClient({
65
+ ...baseConfig,
66
+ endpoint: isLocal ? endpoints.eventbridge : undefined
67
+ });
68
+
69
+ export {
70
+ dynamoDB,
71
+ dynamoDBClient,
72
+ s3,
73
+ sqs,
74
+ sns,
75
+ eventbridge,
76
+ isLocal,
77
+ endpoints,
78
+ baseConfig as config
79
+ };
80
+
81
+ export default {
82
+ dynamoDB,
83
+ dynamoDBClient,
84
+ s3,
85
+ sqs,
86
+ sns,
87
+ eventbridge,
88
+ isLocal,
89
+ endpoints,
90
+ config: baseConfig
91
91
  };