first version
This commit is contained in:
28
s3-list.ts
Normal file
28
s3-list.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config({ path: '.env' });
|
||||
|
||||
import { S3Client, ListBucketsCommand } from '@aws-sdk/client-s3';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
|
||||
// Aktiviere KeepAlive für stabile Connections (verhindert Timeouts bei Wiederholungen)
|
||||
http.globalAgent.keepAlive = true;
|
||||
https.globalAgent.keepAlive = true;
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Fetching S3 buckets...');
|
||||
const s3 = new S3Client({
|
||||
region: process.env.AWS_REGION,
|
||||
credentials: {
|
||||
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
|
||||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
|
||||
},
|
||||
httpOptions: { connectTimeout: 30000, timeout: 30000 }, // Erhöhte Timeouts (30s) verhindern ETIMEDOUT
|
||||
});
|
||||
const { Buckets } = await s3.send(new ListBucketsCommand({}));
|
||||
console.log('Buckets:', Buckets?.map(b => b.Name) || 'No buckets found');
|
||||
} catch (error) {
|
||||
console.error('Error listing buckets:', error);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user