Reputation: 99
The lambda function handler below does not log anything after the line console.log('Getting already imported files list...');
. The function just times out (30s for example).
The bucket 'testbucket' is not available (intentionally). Though, I am not getting any error messages or other log messages. How can I enable them?
import { ListObjectsV2Command, S3Client } from '@aws-sdk/client-s3';
export const handler = async (): Promise<unknown> => {
try {
const s3Client = new S3Client({
region: 'eu-west-3',
logger: {
error: (...messages: string[]): void => console.log(...messages),
warn: (...messages: string[]): void => console.log(...messages),
info: (...messages: string[]): void => console.log(...messages),
debug: (...messages: string[]): void => console.log(...messages),
},
maxAttempts: 1,
});
console.log('Getting already imported files list...');
const res = await s3Client.send(
new ListObjectsV2Command({
Bucket: 'testbucket',
}),
);
console.log({ res });
console.log('Ended :)');
return {
statusCode: 200,
message: 'ok?',
};
} catch (error) {
console.log('Error caught...');
console.log(error);
return {
statusCode: 500,
message: 'Internal server error.',
};
}
};
Upvotes: 0
Views: 340