| 1 | /** |
| 2 | * SQS-consumer fixture for the floci dev ESM test, deployed with |
| 3 | * `bundle: false` (the directory ships as-is). Plain `.mjs` because |
| 4 | * `@aws-sdk/client-s3` is not a workspace dependency — the Lambda runtime |
| 5 | * image provides it, and floci injects `AWS_ENDPOINT_URL` + placeholder |
| 6 | * credentials so the SDK targets the emulator. Path-style is forced because |
| 7 | * virtual-host bucket DNS does not resolve locally. |
| 8 | */ |
| 9 | import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"; |
| 10 | |
| 11 | const s3 = new S3Client({ |
| 12 | endpoint: process.env.AWS_ENDPOINT_URL, |
| 13 | forcePathStyle: true, |
| 14 | }); |
| 15 | |
| 16 | export const handler = async (event) => { |
| 17 | for (const record of event.Records ?? []) { |
| 18 | await s3.send( |
| 19 | new PutObjectCommand({ |
| 20 | Bucket: process.env.TARGET_BUCKET, |
| 21 | Key: record.body, |
| 22 | Body: record.messageId, |
| 23 | }), |
| 24 | ); |
| 25 | } |
| 26 | return { batchItemFailures: [] }; |
| 27 | }; |