Utility scripts to help test the PDF Converter API against your deployed production environment.
Ruby: The scripts require Ruby to be installed. They use bundler/inline to automatically install required gems on first run.
AWS Credentials: Ensure your AWS credentials are configured:
aws configureThe scripts will automatically install their dependencies (JWT, AWS SDK) when first run - no manual gem installation needed!
Generate a JWT token for API authentication:
./scripts/generate_jwt_token.rbThe script retrieves the JWT secret from AWS Secrets Manager and generates a valid token.
Options:
./scripts/generate_jwt_token.rb [options]
Options:
-s, --secret SECRET JWT secret (if not using AWS Secrets Manager)
-n, --secret-name NAME AWS Secrets Manager secret name (default: pdf-converter/jwt-secret)
-r, --region REGION AWS region (default: us-east-1)
-e, --expiration SECONDS Token expiration in seconds (default: 3600)
-u, --subject SUBJECT Token subject/user identifier (default: test-user)
-h, --help Show help messageExample:
# Generate token with default settings
./scripts/generate_jwt_token.rb
# Generate token with 2-hour expiration
./scripts/generate_jwt_token.rb --expiration 7200
# Use a different secret name
./scripts/generate_jwt_token.rb --secret-name my-app/jwt-secret --region us-west-2Generate pre-signed S3 URLs for source PDF and destination folder:
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/test.pdf \
--dest-prefix output/Required Arguments:
--bucket BUCKET: S3 bucket name--source-key KEY: S3 key for source PDF (e.g., 'pdfs/test.pdf')--dest-prefix PREFIX: S3 prefix for destination images (e.g., 'output/')
Optional Arguments:
-r, --region REGION AWS region (default: us-east-1)
-e, --expiration SECONDS URL expiration in seconds (default: 3600)
-u, --unique-id ID Unique ID for this conversion (default: test-TIMESTAMP)
-f, --format FORMAT Output format: pretty, json, curl (default: pretty)
-h, --help Show help messageOutput Formats:
pretty: Human-readable output with JSON payload (default)json: JSON output for programmatic usecurl: Ready-to-use curl command template
Examples:
# Generate URLs with pretty output
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/sample.pdf \
--dest-prefix converted/
# Generate URLs as JSON
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/sample.pdf \
--dest-prefix converted/ \
--format json
# Generate URLs with curl template
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/sample.pdf \
--dest-prefix converted/ \
--format curl
# Custom expiration and unique ID
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/sample.pdf \
--dest-prefix converted/ \
--expiration 7200 \
--unique-id my-test-123Here's how to test your deployed API end-to-end:
aws s3 cp test.pdf s3://my-bucket/pdfs/test.pdf./scripts/generate_jwt_token.rbCopy the token from the output.
./scripts/generate_presigned_urls.rb \
--bucket my-bucket \
--source-key pdfs/test.pdf \
--dest-prefix output/Copy the JSON payload from the output.
Use the JWT token and JSON payload to call your deployed API:
curl -X POST https://your-api-id.execute-api.us-east-1.amazonaws.com/Prod/convert \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"source": "https://s3.amazonaws.com/...",
"destination": "https://s3.amazonaws.com/...",
"unique_id": "test-123"
}'# List converted images
aws s3 ls s3://my-bucket/output/
# Download an image to verify
aws s3 cp s3://my-bucket/output/test-123-0.png ./Make sure you've configured AWS CLI:
aws configureEnsure the JWT secret exists in AWS Secrets Manager:
aws secretsmanager describe-secret --secret-id pdf-converter/jwt-secretYour AWS user/role needs these permissions:
s3:GetObjecton the source buckets3:PutObjecton the destination bucketsecretsmanager:GetSecretValuefor the JWT secret