Skip to content

Commit d00284a

Browse files
[dev] [Marfuen] mariano/more-6 (#1586)
--------- Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent 8606ed8 commit d00284a

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

apps/app/src/jobs/tasks/automation/execute-script.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { getModelOptions } from '@/ai/gateway';
2-
import { s3Client } from '@/app/s3';
32
import { decrypt, type EncryptedData } from '@/lib/encryption';
4-
import { GetObjectCommand } from '@aws-sdk/client-s3';
3+
import { GetObjectCommand, S3Client } from '@aws-sdk/client-s3';
54
import { db } from '@db';
65
import { logger, queue, task } from '@trigger.dev/sdk';
76
import { generateObject } from 'ai';
@@ -38,13 +37,29 @@ export const executeAutomationScript = task({
3837
const { orgId, taskId } = payload;
3938
const logs: string[] = [];
4039

40+
if (
41+
!process.env.APP_AWS_REGION ||
42+
!process.env.APP_AWS_ACCESS_KEY_ID ||
43+
!process.env.APP_AWS_SECRET_ACCESS_KEY
44+
) {
45+
throw new Error('AWS S3 credentials or configuration missing. Check environment variables.');
46+
}
47+
4148
try {
4249
logger.info(`Executing automation script for task ${taskId} in org ${orgId}`);
4350

4451
// Fetch the script from S3
4552
const scriptKey = `${orgId}/${taskId}.automation.js`;
4653
logs.push(`[SYSTEM] Fetching script from S3: ${scriptKey}`);
4754

55+
const s3Client = new S3Client({
56+
region: process.env.APP_AWS_REGION,
57+
credentials: {
58+
accessKeyId: process.env.APP_AWS_ACCESS_KEY_ID,
59+
secretAccessKey: process.env.APP_AWS_SECRET_ACCESS_KEY,
60+
},
61+
});
62+
4863
const { Body } = await s3Client.send(
4964
new GetObjectCommand({
5065
Bucket: process.env.TASKS_AUTOMATION_BUCKET,

0 commit comments

Comments
 (0)