Skip to content

Commit dde0310

Browse files
committed
FEAT: Add static s3 bootstrap file
AWS EMR requires the bootstrap actions to be contained in S3, but this prevents easy tracking using a VCS. Create a static file that can be placed in S3, and called with VCS info to run a dynamic script that is in version control. This means the version of bootstrap scripts is set in the cloudformation template.
1 parent 4a0fb8c commit dde0310

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e -x
3+
4+
# Used to sit in an s3 bucket and will call an arbitrary script, passing in version information
5+
# This is because AWS EMR requires bootstrap actions to be in a bucket, rather than in a VCS.
6+
# e.g. /path/to/this_script.sh --path-prefix "https://github.com/<user>/<repo>/raw/<tag>" --bootstrap-file "/path/to/version/controlled/script.sh" -- <script_arguments>
7+
# Will pass --path-prefix to the called script, so it can reference the relevant version in some VCS.
8+
9+
BOOTSTRAP_LOCAL_FILE="/tmp/bootstrap.sh"
10+
11+
error_out ()
12+
{
13+
>&2 echo "Error: $1"
14+
exit 1
15+
}
16+
17+
options=$(getopt -o '' --longoptions path-prefix:,bootstrap-file: -- "$@")
18+
eval set -- "$options"
19+
20+
while true; do
21+
case "$1" in
22+
--path-prefix)
23+
shift
24+
PATH_PREFIX=$1
25+
;;
26+
--bootstrap-file)
27+
shift
28+
BOOTSTRAP_FILE=$1
29+
;;
30+
--)
31+
shift
32+
break
33+
;;
34+
*)
35+
error_out "unrecognised option: $1"
36+
;;
37+
esac
38+
shift
39+
done
40+
41+
if [ -z "$PATH_PREFIX" ]; then
42+
error_out "missing required option: --path-prefix"
43+
fi
44+
if [ -z "$BOOTSTRAP_FILE" ]; then
45+
error_out "missing required option: --bootstrap-file"
46+
fi
47+
48+
curl -L --output "$BOOTSTRAP_LOCAL_FILE" "${PATH_PREFIX}${BOOTSTRAP_FILE}"
49+
sudo chmod +x "$BOOTSTRAP_LOCAL_FILE"
50+
"$BOOTSTRAP_LOCAL_FILE" --path-prefix "$PATH_PREFIX" $@

0 commit comments

Comments
 (0)