-
Notifications
You must be signed in to change notification settings - Fork 11
/
make.jl
70 lines (55 loc) · 2.13 KB
/
make.jl
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using AWSCore
using AWSS3
using AWSLambda
JL_VERSION_BASE="0.6"
JL_VERSION_PATCH="4"
JL_VERSION="$JL_VERSION_BASE.$JL_VERSION_PATCH"
image_name = "octech/$(replace(basename(pwd()), "_", "")):$JL_VERSION"
lambda_name = basename(pwd())
source_bucket = "octech.com.au.ap-southeast-2.awslambda.jl.deploy"
base_zip = "$(lambda_name)_$(VERSION)_$(AWSLambda.aws_lamabda_jl_version).zip"
if length(ARGS) == 0 || ARGS[1] == "build"
cp("../../src/AWSLambda.jl", "AWSLambda.jl"; remove_destination=true)
run(`docker build
--build-arg JL_VERSION_BASE=$JL_VERSION_BASE
--build-arg JL_VERSION_PATCH=$JL_VERSION_PATCH
-t $image_name .`)
end
if length(ARGS) > 0 && ARGS[1] == "shell"
run(`docker run --rm -it -v $(pwd()):/var/host $image_name bash`)
end
if length(ARGS) > 0 && ARGS[1] == "zip"
rm(base_zip; force=true)
cmd = `zip --symlinks -r -9 /var/host/$base_zip .`
run(`docker run --rm -it -v $(pwd()):/var/host $image_name $cmd`)
end
if length(ARGS) > 0 && ARGS[1] == "deploy"
AWSCore.Services.s3("PUT", "/$source_bucket/$base_zip",
headers=Dict("x-amz-acl" => "public-read"),
Body=read(base_zip))
end
if length(ARGS) > 0 && ARGS[1] == "deploy_regions"
lambda_regions = ["us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"ap-northeast-2",
"ap-south-1",
"ap-southeast-1",
"ap-northeast-1",
"eu-central-1",
"eu-west-1",
"eu-west-2"]
@sync for r in lambda_regions
raws = merge(default_aws_config(), Dict(:region => r))
bucket = "octech.com.au.$r.awslambda.jl.deploy"
@async begin
s3_create_bucket(raws, bucket)
AWSS3.s3(default_aws_config(), "PUT", bucket;
path = base_zip,
headers = Dict(
"x-amz-copy-source" => "$source_bucket/$base_zip",
"x-amz-acl" => "public-read"))
end
end
end