AWS Builder Center

Barcode Label Printing using AWS Services

Learn how to design a secure, serverless barcode and QR code printing pipeline using AWS Cognito, Lambda, API Gateway, S3, and RDS. This architecture walks through secure ZPL document management, user authentication, and print tracking while highlighting key cost-optimization choices.

Have you ever seen a box of product packaging that has barcodes or QR Codes? Have you ever wondered how it was done?

I know for sure, we all saw one. So, I decided to design one.

Requirement/s:

  1. Must have authentication
  1. Barcode should be accessible to any location.
  1. Use ZPL.
  1. Printing of barcode or QR Code must be tracked (how many barcodes are being printed and who printed it).
  1. Within a private network.


AWS Services

  • AWS Cognito — For User Authentication
  • AWS S3 Bucket — For the ZPL document storage
  • AWS RDS — For Database transaction/s
  • AWS API Gateway — For API endpoints
  • AWS Lambda — For Business Process attached to each API Endpoint
  • AWS API Gateway Endpoint for S3 — For secure connection between lambda and S3


What is ZPL?

ZPL is a print language used by many label printers. A print language is a set of commands that can be used to draw elements like text, shapes, barcodes and images, combine these elements, and finally print them.


ZPL Barcode

Sample ZPL - source: labelary.com


The Architecture


ZPL Barcode Printing Architecture



Process

  1. A user will open the web application and login
  1. The login will invoke a request to AWS Cognito to authenticate the user
  1. If creating a new ZPL, the user will create the ZPL in the frontend and then trigger the create ZPL.
  1. With AWS Cognito token attached on the request, AWS API Gateway will natively validate the request and authorized it via User Pool in which a permission to invoke create ZPL lambda is attached.
  1. The lambda will then put the ZPL document in the S3 bucket via secured API Gateway s3 endpoint. This gateway provides a secured connection between lambda and s3 bucket.
  1. The metadata and the signed URL will then be saved to RDS.
  1. If retrieving the ZPL to print, With AWS Cognito token attached on the request, AWS API Gateway will natively validate the request and authorized it via User Pool in which a permission to invoke retrieve ZPL lambda is attached.
  1. The lambda will get the metadata from RDS and then match the meta data to S3 bucket and will display back to the frontend.
  1. The user will then print it via the browser functionality going to a connected printer device.
  1. An audit request will be sent to the lambda authenticated and authorized by AWS Cognito and AWS API Gateway, the Audit Lambda will invoke and save the record in RDS.


The Cost


Service
Billed Component
Monthly Cost
Amazon Cognito
<10,000 MAUs (Free Tier)
$0.00
Amazon S3
Storage & API Calls (~100k requests)
~$0.55
Amazon RDS
db.t4g.micro + 20 GB Storage
~$14.50
Amazon API Gateway
HTTP API (100k requests)
~$0.10
AWS Lambda
Requests & Compute (Free Tier)
$0.00
VPC Gateway Endpoint
Unlimited routing (Always Free)
$0.00
ESTIMATED TOTAL

~$15.15 / month

Overall, this is a simple label printing that gives you the output of Barcode, or any type of Code Available and supported by ZPL.

Everything in the cloud works smoothly. Cognito authenticates S3 fetches the ZPL and the API returns the ZPL payload.. When you click print the browser tries to format the ZPL as a standard page. That turns your ZPL into a blurry image or PDF that warehouse scanners cannot read.

How would you bridge the gap, between the web browser and the physical thermal printer to send ZPL directly?

I'll leave this one open - how would you solve it?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article