s3-resource-simple/assets/check

16 lines
444 B
Bash
Executable file

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