lamma 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 48c666ef5bf2f86912462d63b6e29c20165c1bfd
4
- data.tar.gz: bb28bc07806ce282888ceb94431b56d513fc42f1
2
+ SHA256:
3
+ metadata.gz: c924bb615fcc7c4b5f4baa03624dddf90cb7ab4b6836ac0921658f2477b9e258
4
+ data.tar.gz: 7b645cecaf5342501c9b8b256861e156f6f1231b38da0b0c0f906dcb6600ce18
5
5
  SHA512:
6
- metadata.gz: 3a53c581460c7981e90c9258f169b0180b7fd3d7b254b4448f7acbf939ce844ffebc45662c010e699c0641cabb11252fb1d0a205b299957335f5d1565d3acdbe
7
- data.tar.gz: 8642d8f477ca8ac025c7b52be42504395a3f6a49bbbc1030c60f9e624f161eec960b9028ab24ecdd99387f7c96b04c6dc3d61e39ab0dbfa36c117d873e711fff
6
+ metadata.gz: 74b3b5bd632f8fd27a6b7d6c84779952476df001b3d47b26c6a2c3e55a03ff72f564c71c1283001d3ab7a15884c15d9115a6d06dfc71452734b41df434f9914f
7
+ data.tar.gz: 2e4d4b8e122a32eca8e92856d42473b2050e09a3c4d204c7d03e211932f0de856cb5b3463c29ee388241beec9d63fb1f8e852ae37e70f937f0d3460c88045bd7
@@ -20,3 +20,4 @@ deploy:
20
20
  on:
21
21
  tags: true
22
22
  repo: ayemos/lamma
23
+ rvm: 2.4.0
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![Test Coverage](https://codeclimate.com/github/ayemos/lamma/badges/coverage.svg)](https://codeclimate.com/github/ayemos/lamma/coverage)
5
5
  [![Issue Count](https://codeclimate.com/github/ayemos/lamma/badges/issue_count.svg)](https://codeclimate.com/github/ayemos/lamma)
6
6
 
7
- It will help [Amazon Lambda](http://aws.amazon.com/lambda/) developer to,
7
+ It will help [AWS Lambda](http://aws.amazon.com/lambda/) developers to,
8
8
  - Create new function,
9
9
  - Deploy current code,
10
10
  - and to Rollback last deployment.
@@ -35,15 +35,21 @@ export AWS_ACCESS_KEY_ID = [YOUR_AWS_ACCESS_KEY_ID]
35
35
  export AWS_SECRET_ACCESS_KEY = [YOUR_AWS_SECRET_ACCESS_KEY]
36
36
  ```
37
37
 
38
+ ## Examples
39
+ see `./examples`
40
+
38
41
  # Todo
39
- - [ ] Support Automatic IAM Role initialization
42
+ - [x] Support Automatic IAM Role initialization
40
43
  - [ ] Support dead letter queue configuration
41
- - [ ] Support environment variables
42
- - [ ] Support KMS encripted variable configuration
44
+ - [x] Support environment variables
45
+ - [x] Support KMS encripted variable configuration
43
46
  - [ ] Support VPC configuration
44
47
  - [ ] Prepare init templates
45
48
  - [x] python2.7
49
+ - [ ] python3
46
50
  - [ ] node4.3
47
51
  - [ ] node4.3 edge
48
52
  - [ ] C#
49
53
  - [ ] Java8
54
+ - [ ] Support permission setting (add another command ?)
55
+ - [ ] Support python3 runtime
@@ -0,0 +1,8 @@
1
+ function:
2
+ name: hello
3
+ role_arn: YOUR_ROLE_ARN
4
+ description: Hello, world.
5
+ timeout: 3
6
+ memory_size: 128
7
+ runtime: python2.7
8
+ region: ap-northeast-1
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "lamma"
8
8
  spec.version = Lamma::VERSION
9
9
  spec.authors = ["Yuichiro Someya"]
10
- spec.email = ["ayemos.y@gmail.com"]
10
+ spec.email = ["me@ayemos.me"]
11
11
 
12
12
  spec.summary = %q{Deploy toolset for Amazon Lambda functions.}
13
13
  spec.description = %q{Deploy toolset for Amazon Lambda functions..}
@@ -20,7 +20,7 @@ module Lamma
20
20
  end
21
21
 
22
22
  desc 'deploy', 'Upload local lambda function to AWS and deploy.'
23
- method_option :path, aliases: '-p', type: :string
23
+ method_option :conf_path, aliases: '-c', type: :string
24
24
  method_option :alias, aliases: '-a', type: :string
25
25
  method_option :message, aliases: '-m', type: :string
26
26
  def deploy
@@ -29,7 +29,7 @@ module Lamma
29
29
  end
30
30
 
31
31
  desc 'rollback', 'Rollback last deploy.'
32
- method_option :path, aliases: '-p', type: :string
32
+ method_option :conf_path, aliases: '-c', type: :string
33
33
  method_option :alias, aliases: '-a', type: :string
34
34
  def rollback
35
35
  require 'lamma/cli/rollback'
@@ -37,7 +37,7 @@ module Lamma
37
37
  end
38
38
 
39
39
  desc 'create', 'Create new remote function.'
40
- method_option :path, aliases: '-p', type: :string
40
+ method_option :conf_path, aliases: '-c', type: :string
41
41
  def create
42
42
  require 'lamma/cli/create'
43
43
  Create.new(options, self).run
@@ -46,6 +46,7 @@ module Lamma
46
46
  desc 'init FUNCTION_NAME', 'Initialize local function'
47
47
  method_option :runtime, aliases: '-r', type: :string, required: true
48
48
  method_option :role_arn, aliases: %w(--role-arn -R), type: :string
49
+ method_option :skip_git, aliases: %w(--skip-git -G), type: :boolean
49
50
  def init(function_name)
50
51
  require 'lamma/cli/init'
51
52
  Init.new(options, function_name, self).run
@@ -5,7 +5,7 @@ module Lamma
5
5
  def initialize(options, thor)
6
6
  @options = options
7
7
  @thor = thor
8
- @conf_path = options[:path] || Lamma::DEFAULT_CONF_PATH
8
+ @conf_path = options[:conf_path] || Lamma::DEFAULT_CONF_PATH
9
9
  end
10
10
 
11
11
  def run
@@ -14,7 +14,7 @@ module Lamma
14
14
  def initialize(options, thor)
15
15
  @options = options
16
16
  @thor = thor
17
- @conf_path = search_conf_path(options['path'] || Lamma::DEFAULT_CONF_PATH)
17
+ @conf_path = search_conf_path(options['conf_path'] || Lamma::DEFAULT_CONF_PATH)
18
18
  end
19
19
 
20
20
  def run
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'aws-sdk'
2
3
  require 'uri'
3
4
  require 'json'
@@ -43,10 +44,12 @@ module Lamma
43
44
 
44
45
  def run
45
46
  if Dir.exist?(target)
46
- abort("Directory '#{target}' already exists.")
47
+ Lamma.logger.fatal "Directory '#{target}' already exists."
48
+ exit(1)
47
49
  end
48
50
 
49
51
  tpath = File.join(File.dirname(__FILE__), '..', 'templates', runtime.to_dirname)
52
+ p tpath
50
53
  templates = Dir.glob(File.join(tpath, '**/*.erb')).map do |path|
51
54
  tar_file = path[tpath.length..path.length - 5] # /foo/bar/templates/RUNTIME/baz/lambda_function.py.erb => /baz/lambda_function.py
52
55
 
@@ -54,7 +57,7 @@ module Lamma
54
57
  end.to_h
55
58
 
56
59
  unless Dir.exist?(target)
57
- FileUtils.makedirs(target)
60
+ ::FileUtils.makedirs(target)
58
61
  end
59
62
 
60
63
  role_arn = options['role_arn']
@@ -82,10 +85,12 @@ module Lamma
82
85
  end
83
86
 
84
87
 
85
- Lamma.logger.info "Initializing git repo in #{target}"
86
- Dir.chdir(target) do
87
- `git init`
88
- `git add .`
88
+ unless options['skip_git']
89
+ p options
90
+ Lamma.logger.info "Initializing git repo in #{target}"
91
+ Dir.chdir(target) do
92
+ `git init`
93
+ end
89
94
  end
90
95
  end
91
96
 
@@ -14,7 +14,7 @@ module Lamma
14
14
  def initialize(options, thor)
15
15
  @options = options
16
16
  @thor = thor
17
- @conf_path = search_conf_path(options['path'] || Lamma::DEFAULT_CONF_PATH)
17
+ @conf_path = search_conf_path(options['conf_path'] || Lamma::DEFAULT_CONF_PATH)
18
18
  end
19
19
 
20
20
  def run
@@ -4,7 +4,7 @@ module Lamma
4
4
  @options = options
5
5
  @thor = thor
6
6
  @function_name = function_name
7
- @conf_path = options[:path] || Lamma::DEFAULT_CONF_PATH
7
+ @conf_path = options[:conf_path] || Lamma::DEFAULT_CONF_PATH
8
8
  end
9
9
 
10
10
  def run
@@ -69,10 +69,10 @@ module Lamma
69
69
  if @prebuild
70
70
  Lamma.logger.info 'Running prebuild script...'
71
71
  raise unless system(@prebuild)
72
- elsif @function.runtime == Lamma::Runtime::PYTHON_27 \
72
+ elsif [Lamma::Runtime::PYTHON_27, Lamma::Runtime::PYTHON_36].include?(@function.runtime.type) \
73
73
  && File.exist?(File.join(@source_path, 'requirements.txt'))
74
74
  raise unless system("pip", "install", "-r", "requirements.txt", "-t", ".")
75
- elsif [Lamma::Runtime::EDGE_NODE_43, Lamma::Runtime::NODE_43].include?(@function.runtime) \
75
+ elsif [Lamma::Runtime::EDGE_NODE_43, Lamma::Runtime::NODE_43].include?(@function.runtime.type) \
76
76
  && File.exist?(File.join(@source_path, 'package.json'))
77
77
  raise unless system("npm", "install", "--production")
78
78
  end
@@ -1,5 +1,7 @@
1
1
  module Lamma
2
2
  class Environment
3
+ attr_accessor :variables
4
+
3
5
  def initialize(yaml)
4
6
  @variables = yaml.fetch('variables', {})
5
7
  end
@@ -152,11 +152,11 @@ module Lamma
152
152
  end
153
153
 
154
154
  def dead_letter_config
155
- DeadLetterConfig.new(@conf.fetch('dead_letter_config', {}))
155
+ @dead_letter_config ||= DeadLetterConfig.new(@conf.fetch('dead_letter_config', {}))
156
156
  end
157
157
 
158
158
  def environment
159
- Environment.new(@conf.fetch('environment', {}))
159
+ @environment ||= Environment.new(@conf.fetch('environment', {}))
160
160
  end
161
161
 
162
162
  def vpc_config
@@ -173,7 +173,7 @@ module Lamma
173
173
  'index.handler'
174
174
  when Runtime::EDGE_NODE_43
175
175
  'index.handler'
176
- when Runtime::PYTHON_27
176
+ when Runtime::PYTHON_27, Runtime::PYTHON_36
177
177
  'lambda_function.lambda_handler'
178
178
  end
179
179
  end
@@ -11,6 +11,7 @@ module Lamma
11
11
  NODE_43 = 30
12
12
  EDGE_NODE_43 = 31
13
13
  PYTHON_27 = 40
14
+ PYTHON_36 = 41
14
15
 
15
16
  def initialize(str)
16
17
  @type =
@@ -25,6 +26,8 @@ module Lamma
25
26
  ::Lamma::Runtime::EDGE_NODE_43
26
27
  when /^python([-_\.\s]*2(\.?7)?)?$/i
27
28
  ::Lamma::Runtime::PYTHON_27
29
+ when /^python([-_\.\s]*3(\.?6)?)?$/i
30
+ ::Lamma::Runtime::PYTHON_36
28
31
  else
29
32
  raise ArgumentError.new("invalid runtime. #{str}")
30
33
  end
@@ -35,7 +38,8 @@ module Lamma
35
38
  JAVA_8 => 'java8',
36
39
  NODE_43 => 'nodejs4.3',
37
40
  EDGE_NODE_43 => 'nodejs4.3-edge',
38
- PYTHON_27 => 'python2.7'
41
+ PYTHON_27 => 'python2.7',
42
+ PYTHON_36 => 'python3.6',
39
43
  }
40
44
 
41
45
  def to_s
@@ -0,0 +1,13 @@
1
+ import json
2
+
3
+
4
+ print('Loading function')
5
+
6
+
7
+ def lambda_handler(event, context):
8
+ #print("Received event: " + json.dumps(event, indent=2))
9
+ print("value1 = " + event['key1'])
10
+ print("value2 = " + event['key2'])
11
+ print("value3 = " + event['key3'])
12
+ return event['key1'] # Echo back the first key value
13
+ #raise Exception('Something went wrong')
@@ -0,0 +1,8 @@
1
+ function:
2
+ name: <%= function_name %>
3
+ role_arn: <%= role_arn %>
4
+ description: Hello, world.
5
+ timeout: 3
6
+ memory_size: 128
7
+ runtime: python3.6
8
+ region: <%= region_or_raise %>
@@ -1,3 +1,3 @@
1
1
  module Lamma
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamma
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichiro Someya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: '3.0'
125
125
  description: Deploy toolset for Amazon Lambda functions..
126
126
  email:
127
- - ayemos.y@gmail.com
127
+ - me@ayemos.me
128
128
  executables:
129
129
  - lamma
130
130
  extensions: []
@@ -163,6 +163,8 @@ files:
163
163
  - lib/lamma/shared_helpers.rb
164
164
  - lib/lamma/templates/python2_7/lambda_function.py.erb
165
165
  - lib/lamma/templates/python2_7/lamma.yml.erb
166
+ - lib/lamma/templates/python3_6/lambda_function.py.erb
167
+ - lib/lamma/templates/python3_6/lamma.yml.erb
166
168
  - lib/lamma/version.rb
167
169
  - lib/lamma/vpc_config.rb
168
170
  homepage: https://github.com/ayemos/Lamma
@@ -186,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
188
  version: '0'
187
189
  requirements: []
188
190
  rubyforge_project:
189
- rubygems_version: 2.4.5
191
+ rubygems_version: 2.7.1
190
192
  signing_key:
191
193
  specification_version: 4
192
194
  summary: Deploy toolset for Amazon Lambda functions.