Skip to content

Instantly share code, notes, and snippets.

@vincentnguyen92
Forked from thesafaraliyev/.env
Created August 19, 2024 02:19
Show Gist options
  • Select an option

  • Save vincentnguyen92/7dba5b4507011ff0c74ef90e733bb0a8 to your computer and use it in GitHub Desktop.

Select an option

Save vincentnguyen92/7dba5b4507011ff0c74ef90e733bb0a8 to your computer and use it in GitHub Desktop.

Revisions

  1. @thesafaraliyev thesafaraliyev revised this gist Jun 14, 2021. No changes.
  2. @thesafaraliyev 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.