Skip to content

Instantly share code, notes, and snippets.

@rgpower
Last active January 5, 2021 22:09
Show Gist options
  • Save rgpower/fde877f7139534fb311b6292d9a320ce to your computer and use it in GitHub Desktop.
Save rgpower/fde877f7139534fb311b6292d9a320ce to your computer and use it in GitHub Desktop.
invoke lambda many times with different payloads, from a sed-based template
# invoke (synchronously) a lambda with a bunch of different uid payloads
cat << EOF > user.lst
abc123
def345
... more...uids...
EOF
cat << EOF > sns.json
{
"Records": [
{
"Sns": {
"MessageId": "165545c9-2a5c-472c-8df2-7ff2be2b3b1b",
"Timestamp": "2021-01-05T07:37:00.000Z",
"TopicArn": "arn:aws:sns:us-east-1:some-acct-id:some-topic",
"Message": "{\"event\":\"activity\",\"uid\":\"TEST_USERID\"}"
}
}
]
}
EOF
for uid in $(cat user.lst); do aws --profile prod lambda invoke --function-name SomeFunctionName --payload $(sed "s/TEST_USERID/$uid/" sns.json | base64) response_$uid.json; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment