-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-layer.ngs
executable file
·32 lines (29 loc) · 1.03 KB
/
make-layer.ngs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ngs
# TODO: Document minimal IAM permissions for this script
# TODO: pin amazonlinux version (tag)
CONTAINER_NAME = 'ngs-make-layer'
F main(src:Dir, build:Bool=true, publish:Bool=true, remove_docker:Bool=true) {
assert(src)
assert(Program('docker'))
script_dir = `line: dirname ${realpath(ARGV0)}`
if build {
$(sudo rm -rf "${script_dir}/out")
$(mkdir -p "${script_dir}/out")
args = Argv({
['--rm']: remove_docker
'--name': CONTAINER_NAME
Repeat('-v'): [
"${src.path}:/make-layer/src:ro"
"${script_dir}:/make-layer/ngs-aws-lambda:ro"
"${script_dir}/out:/make-layer/out:rw"
]
})
$(top_level:: log: docker run $*args amazonlinux /make-layer/ngs-aws-lambda/make-layer.sh)
}
$(log: cd:"out" zip -r - bin lib >layer.zip)
$(log: zip layer.zip bootstrap)
version = read("${script_dir}/out/ngs-version").lines()[0]
if publish {
$(top_level:: log: aws lambda publish-layer-version --layer-name "ngs-${version.replace('.', '-')}" --compatible-architectures x86_64 --zip-file fileb://layer.zip)
}
}