Skip to content

Instantly share code, notes, and snippets.

@humodz
Last active October 28, 2023 19:41
Show Gist options
  • Save humodz/462ce593d577988a1df6b649437a60f4 to your computer and use it in GitHub Desktop.
Save humodz/462ce593d577988a1df6b649437a60f4 to your computer and use it in GitHub Desktop.
localstack s3 + sqs
#!/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