/
lambda.clj
94 lines (64 loc) · 3.09 KB
/
lambda.clj
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
(ns crucible.aws.lambda
(:require [crucible.resources :refer [spec-or-ref defresource]]
[clojure.spec.alpha :as s]))
(s/def ::subnet-id (s/* (spec-or-ref string?)))
(s/def ::security-group-ids (s/* (spec-or-ref string?)))
(s/def ::vpc-config (s/keys :req [::security-group-ids ::subnet-ids]))
(s/def ::timeout (spec-or-ref (s/and pos-int? #(<= % (* 5 60)))))
(s/def ::runtime #{"nodejs"
"nodejs4.3"
"nodejs6.10"
"java8"
"python2.7"
"dotnetcore1.0"
"nodejs4.3-edge"})
(s/def ::role (spec-or-ref string?))
(s/def ::memory-size (spec-or-ref (s/and #(-> % (mod 64) (= 0)) #(<= 128 % 1536))))
(s/def ::handler (spec-or-ref string?))
(s/def ::function-name (spec-or-ref string?))
(s/def ::description (spec-or-ref string?))
(s/def ::s3-bucket (spec-or-ref string?))
(s/def ::s3-key (spec-or-ref string?))
(s/def ::s3-object-version (spec-or-ref string?))
(s/def ::zip-file (spec-or-ref string?))
(s/def ::code (s/keys ::opt [::s3-bucket
::s3-key
::s3-object-version
::zip-file]))
(s/def ::variables (s/map-of (s/or :kw keyword? :str string?) (spec-or-ref string?)))
(s/def ::environment (s/keys :req [::variables]))
(s/def ::reserved-concurrent-executions (spec-or-ref nat-int?))
(s/def ::function (s/keys :req [::code
::handler
::role
::runtime]
:opt [::function-name
::description
::memory-size
::runtime
::vpc-config
::environment
::reserved-concurrent-executions
::timeout]))
(defresource function "AWS::Lambda::Function" ::function)
(s/def ::batch-size (spec-or-ref (s/and pos-int? #(< % 10000))))
(s/def ::enabled (spec-or-ref boolean?))
(s/def ::event-source-arn (spec-or-ref string?))
(s/def ::starting-postition (spec-or-ref #{"TRIM_HORIZON" "LATEST"}))
(s/def ::event-source-mapping (s/keys :req [::event-source-arn
::function-name
::starting-position]
:opt [::batch-size
::enabled]))
(defresource event-source-mapping "AWS::Lambda::EventSourceMapping" ::event-source-mapping)
(s/def ::action (spec-or-ref string?))
(s/def ::function-name (spec-or-ref string?))
(s/def ::principal (spec-or-ref string?))
(s/def ::source-account (spec-or-ref string?))
(s/def ::source-arn (spec-or-ref string?))
(s/def ::permission (s/keys :req [::action
::function-name
::principal]
:opt [::source-account
::source-arn]))
(defresource permission "AWS::Lambda::Permission" ::permission)