iota-rb 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a9d297ba0efe1224491d1e74799dc5cb262deb8
4
+ data.tar.gz: dc6bf64d7f880cdfe33bb0a1ca40f86858783aa0
5
+ SHA512:
6
+ metadata.gz: 2f9e57c3f301b974a27777fbff6c7c170b526b89bc37fbaa14f4d0f65664b13c5bdbac802623ad4b6d122a679cf0b4c14f944afa63a881d2dc9f9b174d94d244
7
+ data.tar.gz: b628d72f25d8fb87d280012b93716e41e2bb7689eca3b328a10d81e5d82bed495c5ea049ee5724500ae44df2892e73729eaa58b083ec8d70cc8c24851ec95840
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalisation:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ Gemfile.lock
32
+ .ruby-version
33
+ .ruby-gemset
34
+
35
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
36
+ .rvmrc
37
+
38
+ *.swp
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iota.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 yuichiro-someya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,74 @@
1
+ [![Build Status](https://travis-ci.org/ayemos/iota.svg)](https://travis-ci.org/ayemos/iota)
2
+
3
+ # Iota
4
+
5
+ It will help [Amazon Lambda](http://aws.amazon.com/lambda/) developer to,
6
+ - Create new function,
7
+ - Deploy current code,
8
+ - and to Rollback last deployment.
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'iota'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install iota
25
+
26
+ ## Configuration
27
+ The gem uses [aws-sdk-ruby](http://aws.amazon.com/sdk-for-ruby/) to get an access to AWS api-es.
28
+
29
+ ``` AWS_ACCESS_KEY_ID ``` and ``` AWS_SECRET_ACCESS_KEY ``` have to be set within your environment.
30
+
31
+ ```
32
+ export AWS_ACCESS_KEY_ID = [YOUR_AWS_ACCESS_KEY_ID]
33
+ export AWS_SECRET_ACCESS_KEY = [YOUR_AWS_SECRET_ACCESS_KEY]
34
+ ```
35
+
36
+ ## Usage & Basic Workflow
37
+
38
+ ### Create new Lambda Function
39
+
40
+ ```
41
+ iota create my_function --runtime nodejs
42
+ ```
43
+
44
+ ### Deploy current code to Remote
45
+
46
+ You have to be in a directory created by 'create' command with 'iota.conf' file.
47
+
48
+ Make some change on nodejs/python2.7 function and
49
+
50
+ ```
51
+ iota deploy production
52
+ or
53
+ iota deploy development
54
+ ```
55
+
56
+ ### Rollback last deploy
57
+
58
+ ```
59
+ iota rollback production
60
+ or
61
+ iota rollback development
62
+ ```
63
+
64
+ You can also check those result vie AWS console.
65
+ (https://[YOUR_REGION].console.aws.amazon.com/lambda/)
66
+
67
+ ## Contributing
68
+
69
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ayemos/iota.
70
+
71
+ ## License
72
+
73
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
74
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "iota"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ retried = false
4
+ begin
5
+ require 'iota'
6
+ require 'iota/cli'
7
+ rescue LoadError
8
+ $:.unshift File.expand_path(File.join(__dir__, '..', 'lib'))
9
+ if retried
10
+ raise
11
+ else
12
+ retried = true
13
+ retry
14
+ end
15
+ end
16
+
17
+ Iota::CLI.start(ARGV)
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iota/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iota-rb"
8
+ spec.version = Iota::VERSION
9
+ spec.authors = ["Yuichiro Someya"]
10
+ spec.email = ["ayemos.y@gmail.com"]
11
+
12
+ spec.summary = %q{Deploy toolset for Amazon Lambda functions.}
13
+ spec.description = %q{Deploy toolset for Amazon Lambda functions..}
14
+ spec.homepage = "https://github.com/ayemos/iota"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec"
25
+
26
+ spec.add_dependency "aws-sdk", "~> 2"
27
+ spec.add_dependency "thor", "~> 0.19"
28
+ end
@@ -0,0 +1,11 @@
1
+ require 'iota/version'
2
+ require 'iota/function'
3
+
4
+ require 'aws-sdk'
5
+
6
+ module Iota
7
+ module_function
8
+ def client
9
+ @client ||= Aws::Lambda::Client.new
10
+ end
11
+ end
@@ -0,0 +1,49 @@
1
+ require 'iota'
2
+ require 'iota/function'
3
+ require 'thor'
4
+
5
+ module Iota
6
+ class CLI < Thor
7
+ class_option :verbose, aliases: '-v', type: :boolean
8
+ map '--version' => :print_version
9
+
10
+ desc "list-functions", "List lambda functions in AWS"
11
+ def list_functions
12
+ if options[:verbose]
13
+ puts Iota.client.list_functions.functions
14
+ else
15
+ puts Iota.client.list_functions.functions.map(&:function_name)
16
+ end
17
+ end
18
+
19
+ # TODO: deploy {produdcion, development} ...
20
+ desc "deploy {production, development}",
21
+ "Upload local lambda function to AWS and deploy."
22
+ method_option :path, aliases: '-p', type: :string
23
+ def deploy(environment)
24
+ require 'iota/cli/deploy'
25
+ Deploy.new(options, environment.to_sym, self).run
26
+ end
27
+
28
+ desc "rollback {production, development}",
29
+ "Rollback last deploy."
30
+ method_option :path, aliases: '-p', type: :string
31
+ def rollback(environment)
32
+ require 'iota/cli/rollback'
33
+ Rollback.new(options, environment.to_sym, self).run
34
+ end
35
+
36
+ desc "create FUNCTION_NAME", "Create new function."
37
+ method_option :path, aliases: '-p', type: :string
38
+ method_option :runtime, aliases: '-r', type: :string, required: true
39
+ def create(function_name)
40
+ require "iota/cli/create"
41
+ Create.new(options, function_name, self).run
42
+ end
43
+
44
+ desc "--version", "print the version"
45
+ def print_version
46
+ puts Iota::VERSION
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,36 @@
1
+ module Iota
2
+ class CLI::Create
3
+ attr_reader :options, :function_name, :runtime, :thor, :path
4
+
5
+ def initialize(options, function_name, thor)
6
+ @options = options
7
+ @function_name = function_name
8
+ @thor = thor
9
+ @path = options[:path] || File.join('.', function_name)
10
+ @runtime = options[:runtime]
11
+ end
12
+
13
+ def run
14
+ if Dir.exist?(path)
15
+ thor.say("Directory '#{path}' already exists.", :red)
16
+ return
17
+ end
18
+
19
+ unless Iota::Function::DEFAULT_HANDLER.has_key?(runtime)
20
+ thor.say("Please specify valid runtime. (%s)" %
21
+ Iota::Function::DEFAULT_HANDLER.keys.to_s)
22
+ return
23
+ end
24
+
25
+ function = Iota::Function.new(function_name, path)
26
+ thor.say("Creating function at directory #{path}.", :yellow)
27
+ function.create_local(runtime)
28
+ thor.say("Done.", :blue)
29
+
30
+ if function.exists?
31
+ thor.say("Note: Function #{function_name} already exists in remote. \\
32
+ Please be careful to deploy it to remote.", :yellow)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,84 @@
1
+ require 'yaml'
2
+
3
+ module Iota
4
+ class CLI::Deploy
5
+ attr_reader :options, :environment, :thor, :path
6
+
7
+ def initialize(options, environment, thor)
8
+ @options = options
9
+ @environment = environment
10
+ @thor = thor
11
+ @path = options[:path] || '.'
12
+ end
13
+
14
+ def run
15
+ unless File.exists?('./iota.conf')
16
+ thor.say("Config file ('./iota.conf') is missing.", :red)
17
+ return
18
+ end
19
+
20
+ thor.say("Loading configuration.", :yellow)
21
+ config = YAML.load_file('./iota.conf')
22
+ thor.say("Done.", :blue)
23
+
24
+ unless Iota::Function::ENVIRONMENT_ALIAS_NAME_MAP.keys.include?(environment)
25
+ thor.say("Invalid environment #{environment}. \\
26
+ Please specify either 'production' or 'development'.", :red)
27
+ return
28
+ end
29
+
30
+ # TODO: not found
31
+ function_name = config['function_name']
32
+
33
+ function = Iota::Function.new(function_name, path)
34
+ if function.exists?
35
+ thor.say("Updating code...", :yellow)
36
+ function.update_code
37
+ thor.say("Done.", :blue)
38
+ new_version = function.publish_version.version
39
+ thor.say("Latest code is published as version:#{new_version}.", :yellow)
40
+
41
+ aliases = function.list_aliases
42
+
43
+ new_version_alias_name = Iota::Function::ENVIRONMENT_ALIAS_NAME_MAP[environment]
44
+ last_version_alias_name = new_version_alias_name +
45
+ Iota::Function::LAST_VERSION_SUFFIX
46
+
47
+ last_version_alias = aliases.select{|a| a.name == last_version_alias_name}.first
48
+ new_version_alias = aliases.select{|a| a.name == new_version_alias_name}.first
49
+
50
+ # last -> prod/dev, prod/dev -> new_version
51
+ unless last_version_alias.nil? || new_version_alias.nil?
52
+ thor.say("Updating aliases...", :yellow)
53
+ function.update_alias(last_version_alias_name, new_version_alias.function_version)
54
+ function.update_alias(new_version_alias_name, new_version)
55
+ thor.say("Done.", :blue)
56
+ else
57
+ thor.say("There's no aliases with name '#{last_version_alias_name}' \
58
+ and/or '#{new_version_alias_name}'.", :red)
59
+ end
60
+ else
61
+ thor.say("Function '#{function_name}' doesn't seem to be exists.", :yellow)
62
+ y_or_n = thor.ask("Do you want to create new function '#{function_name}' ? (y/n)")
63
+ if y_or_n =~ /[yY]/
64
+ thor.say("Creating function '#{function_name}' ...", :yellow)
65
+ begin
66
+ function.create_function(config['runtime'], config['role'])
67
+ rescue ArgumentError
68
+ thor.say("ArgumentError occured. You might need to specify role arn \
69
+ you want to pass to your function via 'iota.conf' file or ENV['AWS_LAMBDA_IAM_ROLE'].", :red)
70
+ return
71
+ end
72
+ thor.say("Done.", :blue)
73
+ thor.say("Setting aliases.", :yellow)
74
+ first_version = function.publish_version.version
75
+ Iota::Function::ENVIRONMENT_ALIAS_NAME_MAP.values.each do |alias_name|
76
+ function.create_alias(alias_name, first_version)
77
+ function.create_alias(alias_name << '_LAST', first_version)
78
+ end
79
+ thor.say("Done.")
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,67 @@
1
+ require 'yaml'
2
+
3
+ module Iota
4
+ class CLI::Rollback
5
+ attr_reader :options, :thor, :path, :environment
6
+
7
+ def initialize(options, environment, thor)
8
+ @options = options
9
+ @environment = environment
10
+ @thor = thor
11
+ @path = options[:path] || '.'
12
+ end
13
+
14
+ def run
15
+ unless File.exists?('./iota.conf')
16
+ thor.say("Config file ('./iota.conf') is missing.", :red)
17
+ return
18
+ end
19
+
20
+ thor.say("Loading configuration.", :yellow)
21
+ config = YAML.load_file('./iota.conf')
22
+ thor.say("Done.", :blue)
23
+
24
+ unless Iota::Function::ENVIRONMENT_ALIAS_NAME_MAP.keys.include?(environment)
25
+ thor.say("Invalid environment #{environment}. \
26
+ Please specify either 'production' or 'development'.", :red)
27
+ return
28
+ end
29
+
30
+ # TODO: not found
31
+ function_name = config['function_name']
32
+
33
+
34
+ function = Iota::Function.new(function_name, path)
35
+ if function.exists?
36
+ aliases = function.list_aliases
37
+
38
+ current_version_alias_name = Iota::Function::ENVIRONMENT_ALIAS_NAME_MAP[environment]
39
+ last_version_alias_name = current_version_alias_name +
40
+ Iota::Function::LAST_VERSION_SUFFIX
41
+
42
+ last_version_alias = aliases.select{|a| a.name == last_version_alias_name}.first
43
+ current_version_alias = aliases.select{|a| a.name == current_version_alias_name}.first
44
+
45
+ # last -> current, current -> last
46
+ unless last_version_alias.nil? || current_version_alias.nil?
47
+ if last_version_alias.function_version == current_version_alias.function_version
48
+ thor.say("Can't rollback before deploy.", :yellow)
49
+ return
50
+ else
51
+ thor.say("Updating alias", :yellow)
52
+ function.update_alias(current_version_alias_name, last_version_alias.function_version)
53
+ thor.say("Version is now at #{last_version_alias.function_version}.", :yellow)
54
+ thor.say("Done.", :blue)
55
+ end
56
+ end
57
+ else
58
+ thor.say("Function #{function_name} doesn't seem to be exists.", :yellow)
59
+ end
60
+ end
61
+
62
+ private
63
+ def templates_path
64
+ File.expand_path(File.join(File.dirname(__FILE__), '../templates'))
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,16 @@
1
+ require 'iota'
2
+ module Iota
3
+ Config = {
4
+ lambda_role: envar(%w(AWS_LAMBDA_IAM_ROLE_ARN AWS_LAMBDA_ROLE_ARN AMAZON_LAMBDA_ROLE_ARN))
5
+ }
6
+
7
+ private
8
+ def envar
9
+ keys.each do |key|
10
+ if ENV.key?(key)
11
+ return ENV[key]
12
+ end
13
+ end
14
+ nil
15
+ end
16
+ end
@@ -0,0 +1,199 @@
1
+ require 'aws-sdk'
2
+ require 'erb'
3
+
4
+ require 'iota'
5
+
6
+ module Iota
7
+ class Function
8
+ DEFAULT_HANDLER = {
9
+ 'nodejs' => {
10
+ handler_name: 'index.handler',
11
+ file_name: 'index.js'
12
+ },
13
+ 'python2.7' => {
14
+ handler_name: 'lambda_function.lambda_handler',
15
+ file_name: 'lambda_function.py'
16
+ }
17
+ }
18
+
19
+ RUNTIMES = DEFAULT_HANDLER.keys
20
+
21
+ ENVIRONMENT_ALIAS_NAME_MAP = {
22
+ production: 'PROD',
23
+ development: 'DEV'
24
+ }
25
+
26
+ # TODO: multiple last_versions, multiple rollback
27
+ PROD_VERSION_ALIAS_NAME = ENVIRONMENT_ALIAS_NAME_MAP[:production]
28
+ DEV_VERSION_ALIAS_NAME = ENVIRONMENT_ALIAS_NAME_MAP[:development]
29
+
30
+ LAST_VERSION_SUFFIX = '_LAST'
31
+
32
+ IGNORES = %w(
33
+ node_modules
34
+ bin
35
+ src
36
+ test
37
+ iota_conf.rb
38
+ )
39
+
40
+ attr_reader :name, :path
41
+
42
+ def initialize(name, path)
43
+ @name = name
44
+ @path = path
45
+ end
46
+
47
+ def create_function(runtime, role)
48
+ if RUNTIMES.include? runtime
49
+ Dir.mktmpdir do |tmpdir|
50
+ zip_file_path = package_function(tmpdir)
51
+
52
+ handler = DEFAULT_HANDLER[runtime]
53
+
54
+ client.create_function({
55
+ function_name: name,
56
+ runtime: runtime,
57
+ handler: handler[:handler_name],
58
+ role: role || ENV['AWS_LAMBDA_IAM_ROLE'],
59
+ code: {
60
+ zip_file: File.open(zip_file_path, "rb")
61
+ }
62
+ })
63
+ end
64
+ end
65
+ end
66
+
67
+ def create_local(runtime)
68
+ Dir.mkdir path
69
+ handler = DEFAULT_HANDLER[runtime]
70
+
71
+ # write function
72
+ File.open(File.join(path, handler[:file_name]), "w") do |file|
73
+ template = File.read(File.join(templates_path, template_file_name[runtime]))
74
+ template_code = ERB.new(template).result(binding)
75
+ file.write(template_code)
76
+ end
77
+
78
+ # write config
79
+ # TODO: 'iota.conf' is hard-coded
80
+ File.open(File.join(path, 'iota.conf'), "w") do |file|
81
+ role = ENV['AWS_LAMBDA_IAM_ROLE'] || ''
82
+ template = File.read(File.join(templates_path, template_file_name['config']))
83
+ template_config = ERB.new(template).result(binding)
84
+ file.write(template_config)
85
+ end
86
+
87
+ path
88
+ end
89
+
90
+ # list versions
91
+ def list_versions
92
+ client.list_versions_by_function({
93
+ function_name: name
94
+ }).versions
95
+ end
96
+
97
+ # list aliases
98
+ def list_aliases
99
+ client.list_aliases({
100
+ function_name: name
101
+ }).aliases
102
+ end
103
+
104
+ def exists?
105
+ begin
106
+ !!remote
107
+ rescue Aws::Lambda::Errors::ResourceNotFoundException
108
+ false
109
+ end
110
+ end
111
+
112
+ def remote
113
+ client.get_function({
114
+ function_name: name
115
+ })
116
+ end
117
+
118
+ def update_alias(alias_, target_version)
119
+ client.update_alias({
120
+ function_name: name,
121
+ name: alias_,
122
+ function_version: target_version
123
+ })
124
+ end
125
+
126
+ def update_code
127
+ Dir.mktmpdir do |tmpdir|
128
+ zip_file_path = package_function(tmpdir)
129
+ resp = client.update_function_code(
130
+ function_name: name,
131
+ zip_file: File.open(zip_file_path, "rb"),
132
+ )
133
+ return resp
134
+ end
135
+ end
136
+
137
+ def publish_version
138
+ client.publish_version({
139
+ function_name: name
140
+ })
141
+ end
142
+
143
+ def create_alias(alias_name, version='$LATEST')
144
+ client.create_alias({
145
+ function_name: name,
146
+ name: alias_name,
147
+ function_version: version
148
+ })
149
+ end
150
+
151
+ private
152
+ def client
153
+ Iota.client
154
+ end
155
+
156
+ def package_function(target_dir)
157
+ unless File.exist?(path) && File.directory?(path)
158
+ # TODO: Change flow
159
+ puts "wrong function path: #{path}"
160
+ end
161
+
162
+ Dir.chdir(path) do
163
+ build_script = File.join("bin", "build")
164
+ if File.exist?(build_script) && File.executable?(build_script)
165
+ puts "Building..."
166
+ system(build_script)
167
+ end
168
+ end
169
+
170
+ Dir[File.join(path, '*')].each do |path|
171
+ next if IGNORES.include?(File.basename(path))
172
+ FileUtils.cp(path, File.join(target_dir, File.basename(path)))
173
+ end
174
+
175
+ Dir.chdir(target_dir) do
176
+ if File.exist?('package.json')
177
+ system("npm", "install", "--production")
178
+ elsif File.exist?('requirements.txt')
179
+ system("pip", "install", "-r", "requirements.txt", "-t", ".")
180
+ end
181
+ system("zip", "-r", "lambda.zip", ".")
182
+ end
183
+
184
+ File.join(target_dir, "lambda.zip")
185
+ end
186
+
187
+ def template_file_name
188
+ {
189
+ 'nodejs' => 'index.js.tt',
190
+ 'python2.7' => 'lambda_function.py.tt',
191
+ 'config' => 'iota.conf.tt'
192
+ }
193
+ end
194
+
195
+ def templates_path
196
+ File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
197
+ end
198
+ end
199
+ end
@@ -0,0 +1,10 @@
1
+ console.log('Loading function');
2
+
3
+ exports.handler = function(event, context) {
4
+ //console.log('Received event:', JSON.stringify(event, null, 2));
5
+ console.log('value1 =', event.key1);
6
+ console.log('value2 =', event.key2);
7
+ console.log('value3 =', event.key3);
8
+ context.succeed(event.key1); // Echo back the first key value
9
+ // context.fail('Something went wrong');
10
+ };
@@ -0,0 +1,3 @@
1
+ function_name: <%= name || '' %>
2
+ runtime: <%= runtime || `` %>
3
+ role: <%= role || '' %>
@@ -0,0 +1,11 @@
1
+ import json
2
+
3
+ print('Loading function')
4
+
5
+ def lambda_handler(event, context):
6
+ #print("Received event: " + json.dumps(event, indent=2))
7
+ print("value1 = " + event['key1'])
8
+ print("value2 = " + event['key2'])
9
+ print("value3 = " + event['key3'])
10
+ return event['key1'] # Echo back the first key value
11
+ #raise Exception('Something went wrong')
@@ -0,0 +1,3 @@
1
+ module Iota
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: iota-rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuichiro Someya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aws-sdk
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.19'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.19'
83
+ description: Deploy toolset for Amazon Lambda functions..
84
+ email:
85
+ - ayemos.y@gmail.com
86
+ executables:
87
+ - iota
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/iota
100
+ - iota.gemspec
101
+ - lib/iota.rb
102
+ - lib/iota/cli.rb
103
+ - lib/iota/cli/create.rb
104
+ - lib/iota/cli/deploy.rb
105
+ - lib/iota/cli/rollback.rb
106
+ - lib/iota/config.rb
107
+ - lib/iota/function.rb
108
+ - lib/iota/templates/index.js.tt
109
+ - lib/iota/templates/iota.conf.tt
110
+ - lib/iota/templates/lambda_function.py.tt
111
+ - lib/iota/version.rb
112
+ homepage: https://github.com/ayemos/iota
113
+ licenses:
114
+ - MIT
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.4.5.1
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Deploy toolset for Amazon Lambda functions.
136
+ test_files: []