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

34 lines
830 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
source=$1
if [ -z "$source" ]; then
echo "usage: $0 </full/path/to/dir>"
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(" ")')
source_dir=$(echo "$payload" | jq -r '.params.source_dir // "."')
test -z "$source_dir" && { echo "Must supply params.source_dir" >&2; exit 1; }
export_aws_vars
cd $source/$source_dir
bucket_uri="s3://$bucket/$prefix"
echo "Uploading '$source_dir' to '$bucket_uri'..."
eval aws $aws_options s3 sync $source/$source_dir $bucket_uri $options
echo "Done."
emit_version