Last active
October 28, 2023 19:41
-
-
Save humodz/462ce593d577988a1df6b649437a60f4 to your computer and use it in GitHub Desktop.
localstack s3 + sqs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
apt-get install jq -y >/dev/null &2>1 | |
UPLOAD_QUEUE_URL="$( | |
awslocal sqs create-queue --queue-name uploads | | |
jq -r .QueueUrl | |
)" | |
echo UPLOAD_QUEUE_URL: "$UPLOAD_QUEUE_URL" | |
UPLOAD_QUEUE_ARN="$( | |
awslocal sqs get-queue-attributes \ | |
--queue-url "$UPLOAD_QUEUE_URL" \ | |
--attribute-names QueueArn | | |
jq .Attributes.QueueArn | |
)" | |
echo UPLOAD_QUEUE_ARN: "$UPLOAD_QUEUE_ARN" | |
awslocal s3api create-bucket \ | |
--bucket files \ | |
--create-bucket-configuration LocationConstraint="$AWS_DEFAULT_REGION" | |
awslocal s3api put-bucket-notification-configuration \ | |
--bucket files --notification-configuration ' | |
{ | |
"QueueConfigurations": [ | |
{ | |
"QueueArn": '"$UPLOAD_QUEUE_ARN"', | |
"Events": ["s3:ObjectCreated:*"] | |
} | |
] | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment