Skip to content

Instantly share code, notes, and snippets.

@thesafaraliyev
Last active December 13, 2024 14:32
Show Gist options
  • Save thesafaraliyev/1621ab75cc92b860efd0cb2e7a2fd5cb to your computer and use it in GitHub Desktop.
Save thesafaraliyev/1621ab75cc92b860efd0cb2e7a2fd5cb to your computer and use it in GitHub Desktop.

Revisions

  1. thesafaraliyev revised this gist Jun 14, 2021. No changes.
  2. thesafaraliyev created this gist Jun 14, 2021.
    10 changes: 10 additions & 0 deletions .env
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    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/
    68 changes: 68 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    ## Amazon CLI commands to manage S3 and SQS in Localstack and Laravel setup guideline.

    ### S3 commands

    #### To create new bucket:

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

    #### Object list in bucket:

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

    ### SQS commands

    #### To create new queue

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

    #### List available queues:

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

    #### Job list in queue:

    * The latest job:
    ```bash
    aws --endpoint-url=http://localhost:4566 sqs receive-message --queue-url http://localhost:4566/000000000000/your-queue-name
    ```
    * The latest 10 jobs:
    ```bash
    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:

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

    #### Delete specific queue:

    ```bash
    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](http://localhost:4566/)).
    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.