sfn-lambda 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +17 -7
- data/lib/sfn-lambda/inject.rb +13 -6
- data/lib/sfn-lambda/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34e8c66fc19d1b07f06a4a99dc65d7f4bc4e33a7
|
4
|
+
data.tar.gz: 27c8d94e336a916720f140a2a1ca353f46fbe5c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3289f7ecbd543648780808f02e2cddd4bd5bdf87ee98e8d762a9b6fc7bd9d952975db608f975d003271673f52e99d2141632fa11ba9de6f1e23ba5be7cd84d5
|
7
|
+
data.tar.gz: 058abcd791ff17fc0759285ca68c981490cba18e223cec9899caf64400e5bba75f6af86899c2e1c62a7e6e85b6fd123c261c790f53ff58b4c7990c4aaa1e15b8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,7 @@ Now enable the `sfn-lambda` callback in the `.sfn` configuration file:
|
|
37
37
|
Configuration.new do
|
38
38
|
...
|
39
39
|
callbacks do
|
40
|
+
require ['sfn-lambda']
|
40
41
|
default ['lambda']
|
41
42
|
end
|
42
43
|
...
|
@@ -112,7 +113,7 @@ Using the python example described within the lambda documentation:
|
|
112
113
|
|
113
114
|
we can define our handler code:
|
114
115
|
|
115
|
-
* `./lambda/python2.7/
|
116
|
+
* `./lambda/python2.7/my_function.py`
|
116
117
|
|
117
118
|
```python
|
118
119
|
def my_handler(event, context):
|
@@ -129,7 +130,15 @@ the newly created file:
|
|
129
130
|
|
130
131
|
```ruby
|
131
132
|
SparkleFormation.new(:lambda_test) do
|
132
|
-
lambda!(:my_handler)
|
133
|
+
lambda!(:my_function, :handler => :my_handler)
|
134
|
+
end
|
135
|
+
```
|
136
|
+
|
137
|
+
If the handler argument is not specified the default value is 'handler'.
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
SparkleFormation.new(:lambda_test) do
|
141
|
+
lambda!(:my_function)
|
133
142
|
end
|
134
143
|
```
|
135
144
|
|
@@ -142,8 +151,9 @@ $ sfn print --file lambda_test
|
|
142
151
|
"MyHandlerLambdaFunction": {
|
143
152
|
"Type": "AWS::Lambda::Function",
|
144
153
|
"Properties": {
|
145
|
-
"Handler": "
|
146
|
-
"
|
154
|
+
"Handler": "index.my_handler",
|
155
|
+
"Runtime": "python2.7"
|
156
|
+
"FunctionName": "my_function",
|
147
157
|
"ZipFile": "def my_handler(event, context):\n message = 'Hello {} {}!'.format(event['first_name'], event['last_name'])\n return {\n 'message' : message\n }\n\n"
|
148
158
|
}
|
149
159
|
}
|
@@ -156,7 +166,7 @@ can be specified within the call:
|
|
156
166
|
|
157
167
|
```ruby
|
158
168
|
SparkleFormation.new(:lambda_test) do
|
159
|
-
lambda!(:my_handler, :runtime => 'python2.7')
|
169
|
+
lambda!(:my_function, :handler => :my_handler, :runtime => 'python2.7')
|
160
170
|
end
|
161
171
|
```
|
162
172
|
|
@@ -165,8 +175,8 @@ custom name can be added as well:
|
|
165
175
|
|
166
176
|
```ruby
|
167
177
|
SparkleFormation.new(:lambda_test) do
|
168
|
-
lambda!(:
|
169
|
-
lambda!(:
|
178
|
+
lambda!(:my_function, :first, :handler => :my_handler, :runtime => 'python2.7')
|
179
|
+
lambda!(:my_function, :second, :handler => :my_handler, :runtime => 'python2.7')
|
170
180
|
end
|
171
181
|
```
|
172
182
|
|
data/lib/sfn-lambda/inject.rb
CHANGED
@@ -10,8 +10,12 @@ class SparkleFormation
|
|
10
10
|
end
|
11
11
|
__t_stringish(fn_name)
|
12
12
|
__t_stringish(fn_uniq_name) unless fn_uniq_name.is_a?(::NilClass)
|
13
|
+
fn_handler = 'handler'
|
13
14
|
if(fn_opts)
|
14
15
|
fn_runtime = fn_opts[:runtime] if fn_opts[:runtime]
|
16
|
+
fn_handler = fn_opts[:handler] if fn_opts[:handler]
|
17
|
+
fn_role = fn_opts[:role] if fn_opts[:role]
|
18
|
+
fn_function_name = fn_opts[:function_name] if fn_opts[:function_name]
|
15
19
|
end
|
16
20
|
unless(fn_runtime.is_a?(::NilClass))
|
17
21
|
__t_stringish(fn_runtime)
|
@@ -21,16 +25,19 @@ class SparkleFormation
|
|
21
25
|
[fn_name, fn_uniq_name].compact.map(&:to_s).join('_'),
|
22
26
|
:resource_name_suffix => :lambda_function
|
23
27
|
)
|
24
|
-
new_fn.properties.handler
|
25
|
-
new_fn.properties.
|
28
|
+
new_fn.properties.handler fn_handler
|
29
|
+
new_fn.properties.runtime lookup[:runtime]
|
30
|
+
new_fn.properties.function_name fn_function_name || fn_name
|
26
31
|
content = ::SfnLambda.control.format_content(lookup)
|
27
32
|
if(content[:raw])
|
28
|
-
new_fn.properties.zip_file content[:raw]
|
33
|
+
new_fn.properties.code.zip_file content[:raw]
|
34
|
+
new_fn.properties.handler "index.#{fn_handler}"
|
35
|
+
new_fn.properties.role fn_role
|
29
36
|
else
|
30
|
-
new_fn.properties.s3_bucket content[:bucket]
|
31
|
-
new_fn.properties.s3_key content[:key]
|
37
|
+
new_fn.properties.code.s3_bucket content[:bucket]
|
38
|
+
new_fn.properties.code.s3_key content[:key]
|
32
39
|
if(content[:version])
|
33
|
-
new_fn.properties.s3_object_version content[:version]
|
40
|
+
new_fn.properties.code.s3_object_version content[:version]
|
34
41
|
end
|
35
42
|
end
|
36
43
|
new_fn
|
data/lib/sfn-lambda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfn-lambda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sparkle_formation
|