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

34 lines
758 B
Bash
Executable file

#!/bin/sh
set -e
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
dest=$1
if [ -z "$dest" ]; then
echo "usage: $0 <path/to/volume>"
exit 1
fi
source "$(dirname $0)/common.sh"
payload=`cat`
bucket=$(get_bucket)
prefix=$(get_prefix)
aws_options=$(echo "$payload" | jq -r '.source.aws_options // [] | join(" ")')
options=$(echo "$payload" | jq -r '.params.options // [] | join(" ")')
skip_download=$(echo "$payload" | jq -r '.params.skip_download // false')
export_aws_vars
if [ "$skip_download" = "true" ]; then
echo "Skipping download from S3"
else
echo "Downloading from S3..."
eval aws $aws_options s3 sync "s3://$bucket/$prefix" $dest $options
echo "Done."
fi
emit_version