2016-03-10 18:18:11 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
source "$(dirname $0)/common.sh"
|
2016-03-22 22:29:42 +01:00
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
payload=`cat`
|
|
|
|
bucket=$(get_bucket)
|
2018-10-30 01:56:37 +01:00
|
|
|
prefix=$(get_prefix)
|
2021-03-25 01:57:12 +01:00
|
|
|
aws_options=$(echo "$payload" | jq -r '.source.aws_options // [] | join(" ")')
|
2016-08-18 11:31:03 +02:00
|
|
|
|
2018-10-26 21:51:51 +02:00
|
|
|
export_aws_vars
|
2016-03-22 22:29:42 +01:00
|
|
|
|
|
|
|
# Consider the most recent LastModified timestamp as the most recent version.
|
2021-03-25 01:57:12 +01:00
|
|
|
timestamps=$(aws $aws_options s3api list-objects --bucket $bucket --prefix "$prefix" --query 'Contents[].{LastModified: LastModified}')
|
2016-03-22 22:29:42 +01:00
|
|
|
recent="$(echo $timestamps | jq -r 'max_by(.LastModified)')"
|
|
|
|
echo "[$recent]"
|