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
# Usage: wait_for_dynamo_record | |
# | |
# Checks to see if Lambda has run to save the sizing in dynamo | |
wait_for_dynamodb_record() { | |
local response=$(check_dynamodb_record) | |
local count=1 | |
while [ -z "$response" ]; do | |
if [ $count -ge $WAITER_ATTEMPTS ]; then | |
local timeout=$(($WAITER_ATTEMPTS * $WAITER_INTERVAL)) | |
msg "No item from DynamoDB found within $timeout seconds" | |
return 1 | |
fi | |
msg "No item in DynamoDB yet..." | |
sleep $WAITER_INTERVAL | |
response=$(check_dynamodb_record) | |
count=$(($count + 1)) | |
done | |
msg "Item found in DynamoDB." | |
return 0 | |
} | |
# Usage: check_dynamodb_record | |
# | |
# Checks if an item exists in the $TABLE_NAME DynamoDB table with the $DEPLOYMENT_ID. | |
# Returns 0 if an item was returned, 1 if no item was returned. | |
check_dynamodb_record() { | |
local response=$($AWS_CLI dynamodb get-item --table-name $TABLE_NAME \ | |
--key '{"deploymentId":{"S":"'$DEPLOYMENT_ID'"}}') | |
if [ -z "$response" ]; then | |
return 1 | |
else | |
echo $response | |
return 0 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment