Created
January 29, 2018 02:14
-
-
Save krishnan-mani/c9a064a3a40d5df42bedcc7bd9ae45b4 to your computer and use it in GitHub Desktop.
Put an item in DynamoDB with a one day TTL
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 | |
set -euxo pipefail | |
TABLE_NAME="$1" | |
REGION="$2" | |
NOW_IN_MINUTES=$(date +%Y%m%dT%H%M%z) | |
EPOCH_TIME=$(date +%s) | |
ONE_DAY_LATER=$(($EPOCH_TIME+86400)) | |
item={\"id\":{\"S\":\"$NOW_IN_MINUTES\"},\"expireAt\":{\"N\":\"$ONE_DAY_LATER\"},\"hostname\":{\"S\":\"$(hostname)\"}} | |
echo $item > item.json | |
aws --region $REGION dynamodb put-item --table-name $TABLE_NAME --item file://item.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment