Skip to content

Instantly share code, notes, and snippets.

@lizturp
Last active November 18, 2015 16:43
Show Gist options
  • Select an option

  • Save lizturp/4c61c0e1e8ed561aeaaa to your computer and use it in GitHub Desktop.

Select an option

Save lizturp/4c61c0e1e8ed561aeaaa to your computer and use it in GitHub Desktop.
Launch AWS Datapipeline from Bash Script
#!/bin/bash
usage() {
echo "
Usage:
-e Environment (dev, stage, prod)
"
}
while getopts "e:" flag
do
case $flag in
e) ENVIRONMENT=$OPTARG
;;
esac
done
shift $((OPTIND-1)) #This tells getopts to move on to the next argument.
if ! [ -s ./definition.json -a -s ./values.${ENVIRONMENT}.json ]
then
echo "ERROR: requires ./definition.json and ./values.${ENVIRONMENT}.json be present and non-empty"
exit 1
fi
if [ "x${ENVIRONMENT}" != "xdev" -a "x${ENVIRONMENT}" != "xstage" -a "x${ENVIRONMENT}" != "xprod" ] ; then
usage
exit 1
fi
ID=$(aws datapipeline create-pipeline --name dds-${ENVIRONMENT}-dp-example --unique-id $(date +%Y%m%d%H%M%S) | jq -r '.pipelineId')
echo "Launched pipeline with ID: ${ID}"
echo "Putting pipeline definition..."
aws datapipeline put-pipeline-definition --pipeline-id ${ID} \
--pipeline-definition file://./definition.json \
--parameter-values-uri file://./values.${ENVIRONMENT}.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment