-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#161 | Script to invoke instant lambda for list of files
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
#file passed to this script is expected to contain records as below (with quotes at start and end) | ||
#"org/d5f28372-038c-4f38-b9b5-62c42b8befb3.jpg" | ||
#"org/6b86b265-3e33-4a80-8077-7b53fc7090d4.png" | ||
|
||
set -e | ||
|
||
for file_name in $(cat $1); do | ||
json_pre='{"Records" : [{"s3": {"bucket": {"name": "prod-user-media"}, "object": {"key":' | ||
json_post='}}}]}' | ||
json_payload="$json_pre $file_name $json_post" | ||
echo "$file_name" | ||
aws lambda invoke --function-name prod-generate-thumbnails-instantly --invocation-type Event --payload "$json_payload" --cli-binary-format raw-in-base64-out /dev/stdout | ||
sleep 0.1 # artificial delay to avoid running into lambda quotas | ||
done |