s3-resource-simple/assets/out
ctro 9eee88b9c2 Address Feedback
- Soft wrapping
- YAML format fix
- Better S3 Docs in README
- No assumptions for defaults in example config
2016-03-21 16:38:36 -06:00

30 lines
826 B
Bash
Executable file

#!/bin/sh
# Resource Impl: http://concourse.ci/implementing-resources.html#out:-update-a-resource.
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
#######################################
# parse incoming config data
payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
options=$(echo "$payload" | jq -r '.source.options // [] | join(" ")')
# 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')
echo "Uploading to S3..."
eval aws s3 sync $source "s3://$bucket" $options
echo "...done."
source "$(dirname $0)/emit.sh" >&3