#!/bin/sh # http://concourse.ci/implementing-resources.html#resource-check set -e # parse incoming config data payload=`cat` bucket=$(echo "$payload" | jq -r '.source.bucket') prefix="$(echo "$payload" | jq -r '.source.path // ""')" # export for `aws` cli export AWS_ACCESS_KEY_ID=$(echo "$payload" | jq -r '.source.access_key_id') export AWS_SECRET_ACCESS_KEY=$(echo "$payload" | jq -r '.source.secret_access_key') # 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]"