1- const localstackHost = `http://${ process . env . LOCALSTACK_HOSTNAME } :${ process . env . EDGE_PORT } ` ;
21const awsSdk = require ( 'aws-sdk' ) ;
3- const sqs = new awsSdk . SQS ( { endpoint :localstackHost } ) ;
4- const ses = new awsSdk . SES ( { endpoint :localstackHost } ) ;
5- const s3 = new awsSdk . S3 ( { endpoint :localstackHost , s3ForcePathStyle : true } ) ;
2+
3+ const endpoint = process . env . AWS_ENDPOINT_URL ;
4+ const sqs = new awsSdk . SQS ( { endpoint : endpoint } ) ;
5+ const ses = new awsSdk . SES ( { endpoint : endpoint } ) ;
6+ const s3 = new awsSdk . S3 ( { endpoint : endpoint , s3ForcePathStyle : true } ) ;
7+ const queueUrl = `${ endpoint } /000000000000/aws-node-sample-transcribe-s3-local-jobs` ;
8+ const transcriptionBucket = process . env . S3_TRANSCRIPTION_BUCKET
69
710// This function consumes the event from s3 PutObject and pushes a new message to SQS.
811const producer = async ( event , context , callback ) => {
912 let statusCode = 200 ;
1013 let message ;
1114
12- const queueUrl = `http://${ process . env . LOCALSTACK_HOSTNAME } :${ process . env . EDGE_PORT } /000000000000/aws-node-sample-transcribe-s3-local-jobs` ;
13-
1415 try {
1516 // Get the record from the s3 event
1617 const records = event . Records ;
1718 const sqsSendMessagePromises = records . map ( ( record ) => {
1819 var jsonContent = "" ;
1920 const params = {
20- Bucket : process . env . S3_TRANSCRIPTION_BUCKET ,
21+ Bucket : transcriptionBucket ,
2122 Key : record . s3 . object . key
2223 } ;
2324 s3 . getObject ( params , ( err , data ) => {
2425 if ( err ) {
25- console . error ( "Error getting object from S3 bucket: " , process . env . S3_TRANSCRIPTION_BUCKET )
26+ console . error ( "Error getting object from S3 bucket: " , transcriptionBucket )
2627 } else {
2728 jsonContent = JSON . parse ( data . Body . toString ( ) ) ;
2829
@@ -78,7 +79,7 @@ const consumer = async (event) => {
7879 } ,
7980 Subject : {
8081 Charset : "UTF-8" ,
81- Data : "Test Email - JOB COMPLETED SUCESSFULLY "
82+ Data : "Test Email - JOB COMPLETED SUCCESSFULLY "
8283 }
8384 } ,
8485 Source : "sender@example.com" // Sender email address
@@ -97,4 +98,4 @@ const consumer = async (event) => {
9798module . exports = {
9899 producer,
99100 consumer,
100- } ;
101+ } ;
0 commit comments