s3-resource-simple/assets/check
2021-03-24 17:57:12 -07:00

17 lines
498 B
Bash
Executable file

#!/bin/sh
set -e
source "$(dirname $0)/common.sh"
payload=`cat`
bucket=$(get_bucket)
prefix=$(get_prefix)
aws_options=$(echo "$payload" | jq -r '.source.aws_options // [] | join(" ")')
export_aws_vars
# Consider the most recent LastModified timestamp as the most recent version.
timestamps=$(aws $aws_options s3api list-objects --bucket $bucket --prefix "$prefix" --query 'Contents[].{LastModified: LastModified}')
recent="$(echo $timestamps | jq -r 'max_by(.LastModified)')"
echo "[$recent]"