Skip to content

Commit

Permalink
feat: reset sqs queue script
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranduy1dol committed Dec 4, 2024
1 parent ce7ca96 commit 4fec1e8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/madara_orchestrator/localstack.star
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ def run(plan, args, suffix):

name = args["name"] + suffix

reset_sqs_file_artifact = plan.upload_file(
src="../scripts/reset_sqs.sh",
)

config = ServiceConfig(
image=args["image"],
ports=ports,
files={"/localstack-setup.sh": reset_sqs_file_artifact},
env_vars={
"DEFAULT_REGION": args["default_region"],
"AWS_ACCESS_KEY_ID": args["aws_access_key_id"],
Expand Down
36 changes: 36 additions & 0 deletions scripts/reset_sqs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash -e

# Set the endpoint URL
ENDPOINT_URL="http://localhost:4566"

# Define an array of queue names
QUEUES=(
"madara_orchestrator_snos_job_processing_queue"
"madara_orchestrator_snos_job_verification_queue"
"madara_orchestrator_proving_job_processing_queue"
"madara_orchestrator_proving_job_verification_queue"
"madara_orchestrator_data_submission_job_processing_queue"
"madara_orchestrator_data_submission_job_verification_queue"
"madara_orchestrator_update_state_job_processing_queue"
"madara_orchestrator_update_state_job_verification_queue"
"madara_orchestrator_job_handle_failure_queue"
"madara_orchestrator_worker_trigger_queue"
)

# Loop through the queues and purge each one
echo "----------------------------"
for QUEUE in "${QUEUES[@]}"; do
QUEUE_URL="${ENDPOINT_URL}/000000000000/${QUEUE}"
echo "Purging queue: ${QUEUE}"
aws --endpoint-url ${ENDPOINT_URL} sqs purge-queue --queue-url "${QUEUE_URL}"
echo "Queue purged: ${QUEUE}"
done

# Loop through the queues and recreate each one
echo "----------------------------"
for QUEUE in "${QUEUES[@]}"; do
echo "Creating queue: ${QUEUE}"
aws --endpoint-url ${ENDPOINT_URL} sqs create-queue --queue-name "${QUEUE}"
done

echo "All queues have been created."

0 comments on commit 4fec1e8

Please sign in to comment.