Skip to content

Commit

Permalink
Update config, localstack to reflect removed queue
Browse files Browse the repository at this point in the history
  • Loading branch information
philmcmahon committed Mar 12, 2024
1 parent 19891be commit ad1332b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/backend-common/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface TranscriptionConfig {
emailNotificationFromAddress: string;
sourceMediaBucket: string;
transcriptionOutputBucket: string;
destinationQueueArns: {
destinationQueueUrls: {
transcriptionService: string;
};
tableName: string;
Expand Down Expand Up @@ -79,7 +79,7 @@ export const getConfig = async (): Promise<TranscriptionConfig> => {
const destinationTopic = findParameter(
parameters,
paramPath,
'destinationQueueArns/transcriptionService',
'destinationQueueUrls/transcriptionService',
);
// AWS clients take an optional 'endpoint' property that is only needed by localstack - on code/prod you don't need
// to set it. Here we inder the endpoint (http://localhost:4566) from the sqs url
Expand Down Expand Up @@ -131,7 +131,7 @@ export const getConfig = async (): Promise<TranscriptionConfig> => {
stage,
sourceMediaBucket,
emailNotificationFromAddress,
destinationQueueArns: {
destinationQueueUrls: {
transcriptionService: destinationTopic,
},
tableName,
Expand Down
9 changes: 5 additions & 4 deletions packages/worker/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const main = async () => {
);

if (config.app.stage !== 'DEV') {
// start job to regularly check the instance interruption
// start job to regularly check the instance interruption (Note: deliberately not using await here so the job
// runs in the background)
checkSpotInterrupt(sqsClient, config.app.taskQueueUrl);
}

Expand Down Expand Up @@ -196,7 +197,7 @@ const pollTranscriptionQueue = async (
}
await publishTranscriptionOutputFailure(
sqsClient,
config.app.destinationQueueArns.transcriptionService,
config.app.destinationQueueUrls.transcriptionService,
job,
);
return;
Expand Down Expand Up @@ -258,7 +259,7 @@ const pollTranscriptionQueue = async (

await publishTranscriptionOutput(
sqsClient,
config.app.destinationQueueArns.transcriptionService,
config.app.destinationQueueUrls.transcriptionService,
transcriptionOutput,
);

Expand Down Expand Up @@ -297,7 +298,7 @@ const pollTranscriptionQueue = async (
if (receiveCount >= MAX_RECEIVE_COUNT) {
await publishTranscriptionOutputFailure(
sqsClient,
config.app.destinationQueueArns.transcriptionService,
config.app.destinationQueueUrls.transcriptionService,
job,
);
}
Expand Down
9 changes: 6 additions & 3 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

SCRIPT_PATH=$( cd $(dirname $0) ; pwd -P )
APP_NAME="transcription-service"


npm install

Expand All @@ -23,16 +23,19 @@ fi

# Starting localstack
docker-compose up -d
APP_NAME="transcription-service"
# If the queue already exists this command appears to still work and returns the existing queue url
QUEUE_URL=$(aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name=$APP_NAME-task-queue-DEV.fifo --attributes "FifoQueue=true,ContentBasedDeduplication=true" | jq .QueueUrl)
# We don't install the localstack dns so need to replace the endpoint with localhost
QUEUE_URL_LOCALHOST=${QUEUE_URL/sqs.eu-west-1.localhost.localstack.cloud/localhost}

echo "Created queue in localstack, url: ${QUEUE_URL_LOCALHOST}"

TOPIC_ARN=$(aws --endpoint-url=http://localhost:4566 sns create-topic --name $APP_NAME-destination-topic-DEV | jq .TopicArn)
OUTPUT_QUEUE_URL=$(aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name=$APP_NAME-output-queue-DEV | jq .QueueUrl)
# We don't install the localstack dns so need to replace the endpoint with localhost
OUTPUT_QUEUE_URL_LOCALHOST=${OUTPUT_QUEUE_URL/sqs.eu-west-1.localhost.localstack.cloud/localhost}

echo "Created topic in localstack, arn: ${TOPIC_ARN}"
echo "Created queue in localstack, url: ${OUTPUT_QUEUE_URL_LOCALHOST}"

DYNAMODB_ARN=$(aws --endpoint-url=http://localhost:4566 dynamodb create-table \
--table-name ${APP_NAME}-DEV \
Expand Down

0 comments on commit ad1332b

Please sign in to comment.