Skip to content

Instantly share code, notes, and snippets.

@thesafaraliyev
Last active October 5, 2023 14:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thesafaraliyev/1621ab75cc92b860efd0cb2e7a2fd5cb to your computer and use it in GitHub Desktop.
Save thesafaraliyev/1621ab75cc92b860efd0cb2e7a2fd5cb to your computer and use it in GitHub Desktop.
Laravel with Localstack S3 and SQS setup
FILESYSTEM_DRIVER=s3
QUEUE_CONNECTION=sqs
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=bucket1
AWS_ENDPOINT=http://localhost:4566/
AWS_USE_PATH_STYLE_ENDPOINT=true
SQS_QUEUE=queue1
SQS_PREFIX=http://localhost:4566/000000000000/

Amazon CLI commands to manage S3 and SQS in Localstack and Laravel setup guideline.

S3 commands

To create new bucket:

aws --endpoint-url=http://localhost:4566 s3 mb s3://your-bucket-name

Object list in bucket:

aws s3api list-objects-v2 --bucket your-bucket-name --endpoint-url http://localhost:4566

SQS commands

To create new queue

aws --endpoint-url=http://localhost:4566 sqs create-queue --queue-name your-queue-name

List available queues:

aws --endpoint-url=http://localhost:4566 sqs list-queues

Job list in queue:

  • The latest job:
    aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url http://localhost:4566/000000000000/your-queue-name
  • The latest 10 jobs:
    aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url http://localhost:4566/000000000000/your-queue-name --max-number-of-messages 10

Purge queue jobs:

aws --endpoint-url=http://localhost:4566 sqs purge-queue --queue-url=http://localhost:4566/000000000000/your-queue-name

Delete specific queue:

aws --endpoint-url=http://localhost:4566 sqs delete-queue --queue-url http://localhost:4566/000000000000/your-queue-name

Laravel configuration

S3 setup

  1. Set FILESYSTEM_DRIVER key value to s3.
  2. Set AWS_USE_PATH_STYLE_ENDPOINT to true
  3. Create a new bucket and set AWS_BUCKET.
  4. Set AWS_ENDPOINT to your host (default localhost).
  5. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY can be omitted since Localstack doesn't check them.

SQS setup

  1. Change QUEUE_CONNECTION key value to sqs.
  2. Create new a queue and set its name to SQS_QUEUE.
  3. Set SQS_PREFIX to QueueUrl which returned after creating new queue without queue name suffix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment