github.com/Jeffail/benthos/v3@v3.65.0/resources/docker/run_all_queues/aws_mk_test_bucket (about)

     1  #!/bin/bash
     2  
     3  aws s3 mb --endpoint http://localhost:4572 s3://benthos-test
     4  
     5  sqs_queue_url=$(aws sqs create-queue \
     6    --endpoint http://localhost:4576 \
     7    --queue-name benthos-test \
     8    --region eu-west-1 \
     9    --attributes 'ReceiveMessageWaitTimeSeconds=20,VisibilityTimeout=300'  \
    10    --output text \
    11    --query 'QueueUrl')
    12  
    13  echo sqs_queue_url=$sqs_queue_url
    14  
    15  sqs_queue_arn=$(aws sqs get-queue-attributes \
    16    --endpoint http://localhost:4576 \
    17    --queue-url "$sqs_queue_url" \
    18    --region eu-west-1 \
    19    --attribute-names QueueArn \
    20    --output text \
    21    --query 'Attributes.QueueArn')
    22  
    23  echo sqs_queue_arn=$sqs_queue_arn
    24  
    25  sqs_policy='{
    26      "Version":"2012-10-17",
    27      "Statement":[
    28        {
    29          "Effect":"Allow",
    30          "Principal": { "AWS": "*" },
    31          "Action":"sqs:SendMessage",
    32          "Resource":"'$sqs_queue_arn'",
    33          "Condition":{
    34            "ArnLike": {
    35              "aws:SourceArn": "arn:aws:s3:*:*:benthos-test"
    36            }
    37          }
    38        }
    39      ]
    40    }'
    41  
    42  sqs_policy_escaped=$(echo $sqs_policy | perl -pe 's/"/\\"/g')
    43  sqs_attributes='{"Policy":"'$sqs_policy_escaped'"}'
    44  aws sqs set-queue-attributes \
    45    --endpoint http://localhost:4576 \
    46    --queue-url "$sqs_queue_url" \
    47    --region eu-west-1 \
    48    --attributes "$sqs_attributes"
    49  
    50  aws s3api put-bucket-notification-configuration \
    51    --endpoint http://localhost:4572 \
    52    --bucket "benthos-test" \
    53    --region eu-west-1 \
    54    --notification-configuration '{
    55      "QueueConfigurations": [{
    56        "Events": [ "s3:ObjectCreated:*" ],
    57        "QueueArn": "'$sqs_queue_arn'"
    58      }]
    59    }'