Sign inSign up

aapjeisbaas/sqs-printer

By aapjeisbaas

Updated about 2 months ago

Image
0

4.8K

aapjeisbaas/sqs-printer repository overview

sqs-printer

This container subscribes to an SQS queue and downloads S3 links posted there to send them to a network printer with pdf-to-ipp

Source Repo

Local run

docker run \
  -e "DESTINATION=http://pdf-to-ipp.thuis/uploader" \
  -e "QUEUE_NAME=packingslip-print" \
  -e "AWS_DEFAULT_REGION=eu-west-1" \
  -e "AWS_ACCESS_KEY_ID=AK******CB" \
  -e "AWS_SECRET_ACCESS_KEY=1P******a" \
  aapjeisbaas/sqs-printer:latest

Test the sqs input

aws sqs send-message --queue-url https://sqs.eu-west-1.amazonaws.com/##########/packingslip-print --message-body '{"bucket": "awesome-bucketname", "key": "packingslips/116544516.pdf"}'

expected test output

Subscribing to sqs: https://eu-west-1.queue.amazonaws.com/##########/packingslip-print
2020-08-28 09:32:35.422806 Done sending pdf to printer: packingslips/116544516.pdf

ENV Vars

KeyValueExplanation
DESTINATIONhttp://pdf-to-ipp.thuis/uploaderpdf-to-ipp http endpoint
QUEUE_NAMEpackingslip-printThe name of your sqs queue
AWS_DEFAULT_REGIONeu-west-1The AWS reqion you want to connect to
AWS_ACCESS_KEY_IDAK******CBAWS cli credentials key
AWS_SECRET_ACCESS_KEY1P******aAWS cli credentials secret

SQS message body

This should be a json body that follows the format below, make sure you have no s3:// in the bucket and no leading / in the key.

{
  "bucket": "awesome-bucketname",
  "key": "packingslips/116544516.pdf"
}

How it works

The script subscribes to the queue and retrieves the messages.

For each message it downloads the file from S3 to /tmp/sqs-printer-pdf-tmp/ and sends the file to the pdf-to-ipp endpoint.

After this the temporary file gets deleted and starts polling for new messages.

Tag summary

Content type

Image

Digest

sha256:d0dba2789

Size

53.6 MB

Last updated

4 months ago

docker pull aapjeisbaas/sqs-printer