m_serverless_hub 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +188 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/serverless_hub +18 -0
- data/bin/setup +8 -0
- data/lib/serverless_hub.rb +10 -0
- data/lib/serverless_hub/authorizer.rb +70 -0
- data/lib/serverless_hub/handler.rb +61 -0
- data/lib/serverless_hub/templates/gitignore +51 -0
- data/lib/serverless_hub/templates/serverless.js +54 -0
- data/lib/serverless_hub/templates/serverless/Dockerfile +8 -0
- data/lib/serverless_hub/templates/serverless/config/serverless.priv.yml +3 -0
- data/lib/serverless_hub/templates/serverless/config/serverless.yml +44 -0
- data/lib/serverless_hub/templates/serverless/package.json +22 -0
- data/lib/serverless_hub/version.rb +3 -0
- data/m_serverless_hub.gemspec +47 -0
- metadata +198 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8f74b3ef19ef43b72cd53d3c0f16618f544baa97995c74443424813503a8a78
|
4
|
+
data.tar.gz: e7c8e5ebba1618861e8607d75875425228ec7ab39409964400f5b6f9dd6e96aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 95f1a41a6f76d3b16e6bd029fc540acfd843660804c1b623dcdd4cc79c67e01a2c50c14940c7f679abaa5f042146b0fdb7bfd74e88baa4d60ae8b5328082d195
|
7
|
+
data.tar.gz: e8f00def4e2014d3bf2859a2f3cbdee5f44decb563d68d24f23b14771fcb77a32cfbbededaaae3745c7cf02722f490a88d7df84a60f4a9189b27df2cd2953a49
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
m_serverless_hub (0.0.1)
|
5
|
+
json-jwt (~> 1.11, >= 1.11.0)
|
6
|
+
jwt (~> 2.1, >= 2.1.0)
|
7
|
+
lamby (~> 1.0, >= 1.0.1)
|
8
|
+
rest-client (~> 2.0, >= 2.0.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actioncable (6.0.3.4)
|
14
|
+
actionpack (= 6.0.3.4)
|
15
|
+
nio4r (~> 2.0)
|
16
|
+
websocket-driver (>= 0.6.1)
|
17
|
+
actionmailbox (6.0.3.4)
|
18
|
+
actionpack (= 6.0.3.4)
|
19
|
+
activejob (= 6.0.3.4)
|
20
|
+
activerecord (= 6.0.3.4)
|
21
|
+
activestorage (= 6.0.3.4)
|
22
|
+
activesupport (= 6.0.3.4)
|
23
|
+
mail (>= 2.7.1)
|
24
|
+
actionmailer (6.0.3.4)
|
25
|
+
actionpack (= 6.0.3.4)
|
26
|
+
actionview (= 6.0.3.4)
|
27
|
+
activejob (= 6.0.3.4)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.0.3.4)
|
31
|
+
actionview (= 6.0.3.4)
|
32
|
+
activesupport (= 6.0.3.4)
|
33
|
+
rack (~> 2.0, >= 2.0.8)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.0.3.4)
|
38
|
+
actionpack (= 6.0.3.4)
|
39
|
+
activerecord (= 6.0.3.4)
|
40
|
+
activestorage (= 6.0.3.4)
|
41
|
+
activesupport (= 6.0.3.4)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.0.3.4)
|
44
|
+
activesupport (= 6.0.3.4)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.0.3.4)
|
50
|
+
activesupport (= 6.0.3.4)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.0.3.4)
|
53
|
+
activesupport (= 6.0.3.4)
|
54
|
+
activerecord (6.0.3.4)
|
55
|
+
activemodel (= 6.0.3.4)
|
56
|
+
activesupport (= 6.0.3.4)
|
57
|
+
activestorage (6.0.3.4)
|
58
|
+
actionpack (= 6.0.3.4)
|
59
|
+
activejob (= 6.0.3.4)
|
60
|
+
activerecord (= 6.0.3.4)
|
61
|
+
marcel (~> 0.3.1)
|
62
|
+
activesupport (6.0.3.4)
|
63
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
|
+
i18n (>= 0.7, < 2)
|
65
|
+
minitest (~> 5.1)
|
66
|
+
tzinfo (~> 1.1)
|
67
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
68
|
+
aes_key_wrap (1.1.0)
|
69
|
+
bindata (2.4.8)
|
70
|
+
builder (3.2.4)
|
71
|
+
concurrent-ruby (1.1.7)
|
72
|
+
crass (1.0.6)
|
73
|
+
diff-lcs (1.3)
|
74
|
+
domain_name (0.5.20190701)
|
75
|
+
unf (>= 0.0.5, < 1.0.0)
|
76
|
+
erubi (1.9.0)
|
77
|
+
globalid (0.4.2)
|
78
|
+
activesupport (>= 4.2.0)
|
79
|
+
http-accept (1.7.0)
|
80
|
+
http-cookie (1.0.3)
|
81
|
+
domain_name (~> 0.5)
|
82
|
+
i18n (1.8.5)
|
83
|
+
concurrent-ruby (~> 1.0)
|
84
|
+
json-jwt (1.13.0)
|
85
|
+
activesupport (>= 4.2)
|
86
|
+
aes_key_wrap
|
87
|
+
bindata
|
88
|
+
jwt (2.1.0)
|
89
|
+
lamby (1.0.2)
|
90
|
+
rack
|
91
|
+
rails
|
92
|
+
loofah (2.7.0)
|
93
|
+
crass (~> 1.0.2)
|
94
|
+
nokogiri (>= 1.5.9)
|
95
|
+
mail (2.7.1)
|
96
|
+
mini_mime (>= 0.1.1)
|
97
|
+
marcel (0.3.3)
|
98
|
+
mimemagic (~> 0.3.2)
|
99
|
+
method_source (1.0.0)
|
100
|
+
mime-types (3.3.1)
|
101
|
+
mime-types-data (~> 3.2015)
|
102
|
+
mime-types-data (3.2020.0512)
|
103
|
+
mimemagic (0.3.5)
|
104
|
+
mini_mime (1.0.2)
|
105
|
+
mini_portile2 (2.4.0)
|
106
|
+
minitest (5.14.2)
|
107
|
+
netrc (0.11.0)
|
108
|
+
nio4r (2.5.4)
|
109
|
+
nokogiri (1.10.10)
|
110
|
+
mini_portile2 (~> 2.4.0)
|
111
|
+
rack (2.2.3)
|
112
|
+
rack-test (1.1.0)
|
113
|
+
rack (>= 1.0, < 3)
|
114
|
+
rails (6.0.3.4)
|
115
|
+
actioncable (= 6.0.3.4)
|
116
|
+
actionmailbox (= 6.0.3.4)
|
117
|
+
actionmailer (= 6.0.3.4)
|
118
|
+
actionpack (= 6.0.3.4)
|
119
|
+
actiontext (= 6.0.3.4)
|
120
|
+
actionview (= 6.0.3.4)
|
121
|
+
activejob (= 6.0.3.4)
|
122
|
+
activemodel (= 6.0.3.4)
|
123
|
+
activerecord (= 6.0.3.4)
|
124
|
+
activestorage (= 6.0.3.4)
|
125
|
+
activesupport (= 6.0.3.4)
|
126
|
+
bundler (>= 1.3.0)
|
127
|
+
railties (= 6.0.3.4)
|
128
|
+
sprockets-rails (>= 2.0.0)
|
129
|
+
rails-dom-testing (2.0.3)
|
130
|
+
activesupport (>= 4.2.0)
|
131
|
+
nokogiri (>= 1.6)
|
132
|
+
rails-html-sanitizer (1.3.0)
|
133
|
+
loofah (~> 2.3)
|
134
|
+
railties (6.0.3.4)
|
135
|
+
actionpack (= 6.0.3.4)
|
136
|
+
activesupport (= 6.0.3.4)
|
137
|
+
method_source
|
138
|
+
rake (>= 0.8.7)
|
139
|
+
thor (>= 0.20.3, < 2.0)
|
140
|
+
rake (13.0.1)
|
141
|
+
rest-client (2.1.0)
|
142
|
+
http-accept (>= 1.7.0, < 2.0)
|
143
|
+
http-cookie (>= 1.0.2, < 2.0)
|
144
|
+
mime-types (>= 1.16, < 4.0)
|
145
|
+
netrc (~> 0.8)
|
146
|
+
rspec (3.9.0)
|
147
|
+
rspec-core (~> 3.9.0)
|
148
|
+
rspec-expectations (~> 3.9.0)
|
149
|
+
rspec-mocks (~> 3.9.0)
|
150
|
+
rspec-core (3.9.0)
|
151
|
+
rspec-support (~> 3.9.0)
|
152
|
+
rspec-expectations (3.9.0)
|
153
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
154
|
+
rspec-support (~> 3.9.0)
|
155
|
+
rspec-mocks (3.9.0)
|
156
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
157
|
+
rspec-support (~> 3.9.0)
|
158
|
+
rspec-support (3.9.0)
|
159
|
+
sprockets (4.0.2)
|
160
|
+
concurrent-ruby (~> 1.0)
|
161
|
+
rack (> 1, < 3)
|
162
|
+
sprockets-rails (3.2.2)
|
163
|
+
actionpack (>= 4.0)
|
164
|
+
activesupport (>= 4.0)
|
165
|
+
sprockets (>= 3.0.0)
|
166
|
+
thor (1.0.1)
|
167
|
+
thread_safe (0.3.6)
|
168
|
+
tzinfo (1.2.7)
|
169
|
+
thread_safe (~> 0.1)
|
170
|
+
unf (0.1.4)
|
171
|
+
unf_ext
|
172
|
+
unf_ext (0.0.7.7)
|
173
|
+
websocket-driver (0.7.3)
|
174
|
+
websocket-extensions (>= 0.1.0)
|
175
|
+
websocket-extensions (0.1.5)
|
176
|
+
zeitwerk (2.4.0)
|
177
|
+
|
178
|
+
PLATFORMS
|
179
|
+
ruby
|
180
|
+
|
181
|
+
DEPENDENCIES
|
182
|
+
bundler (~> 2.0, >= 2.0.2)
|
183
|
+
m_serverless_hub!
|
184
|
+
rake (~> 13.0)
|
185
|
+
rspec (~> 3.0)
|
186
|
+
|
187
|
+
BUNDLED WITH
|
188
|
+
2.1.4
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# ServerlessHub
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/serverless_hub`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'serverless_hub'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install serverless_hub
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/serverless_hub.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "serverless_hub"
|
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(__FILE__)
|
data/bin/serverless_hub
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'serverless_hub'
|
4
|
+
require 'rails/generators'
|
5
|
+
|
6
|
+
class SLSGenerator < Rails::Generators::Base
|
7
|
+
source_root File.expand_path('../lib/serverless_hub/templates/serverless', __dir__)
|
8
|
+
|
9
|
+
def copy
|
10
|
+
directory "./", "./"
|
11
|
+
copy_file "../gitignore", "./.gitignore"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
generator = SLSGenerator.new
|
17
|
+
|
18
|
+
generator.copy
|
data/bin/setup
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "jwt"
|
2
|
+
require "json/jwt"
|
3
|
+
require "rest-client"
|
4
|
+
|
5
|
+
module ServerlessHub
|
6
|
+
class AuthorizerTokenDecoder
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
if env["HTTP_AUTHORIZATION"]
|
13
|
+
tokens = decoded_token(env["HTTP_AUTHORIZATION"])
|
14
|
+
|
15
|
+
if tokens.present?
|
16
|
+
claims = tokens[0]
|
17
|
+
|
18
|
+
env["lambda.event"]["requestContext"]["authorizer"] = {
|
19
|
+
"principalId" => claims["sub"],
|
20
|
+
"claims" => claims,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
return @app.call(env)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.jwks
|
29
|
+
RestClient.get(ENV["JWKS_URL"] || "")
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def decoded_token(token)
|
35
|
+
token = token.strip
|
36
|
+
if token.include? ' '
|
37
|
+
token = token.split(" ").last
|
38
|
+
end
|
39
|
+
decoded = JWT.decode token, jwk_set.first.to_key, false, { algorithm: "RS256" }
|
40
|
+
key_id = decoded[1]['kid']
|
41
|
+
key = jwk_set.find { |key_obj| key_obj['kid'] == key_id }
|
42
|
+
if key == nil
|
43
|
+
return ""
|
44
|
+
end
|
45
|
+
JWT.decode token, key.to_key, true, { algorithm: "RS256" } rescue ""
|
46
|
+
end
|
47
|
+
|
48
|
+
def jwk_set
|
49
|
+
@jwk_set ||= JSON::JWK::Set.new(
|
50
|
+
JSON.parse(
|
51
|
+
AuthorizerTokenDecoder.jwks
|
52
|
+
)
|
53
|
+
)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Authorizer
|
58
|
+
def initialize(app)
|
59
|
+
@app = app
|
60
|
+
end
|
61
|
+
|
62
|
+
def call(env)
|
63
|
+
if env["lambda.event"] && env["lambda.event"]["requestContext"]
|
64
|
+
env["authorizer"] = env["lambda.event"]["requestContext"]["authorizer"]
|
65
|
+
end
|
66
|
+
|
67
|
+
return @app.call(env)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
if ENV["LAMBDA_TASK_ROOT"].present?
|
2
|
+
|
3
|
+
ENV['BUNDLE_GEMFILE'] ||= "#{ENV["LAMBDA_TASK_ROOT"]}/Gemfile.serverless"
|
4
|
+
ENV['BUNDLE_WITHOUT'] ||= "development:test"
|
5
|
+
|
6
|
+
ENV["RAILS_ENV"] ||= "production"
|
7
|
+
|
8
|
+
require "bundler"
|
9
|
+
|
10
|
+
Bundler.setup(:default, ENV["RAILS_ENV"])
|
11
|
+
|
12
|
+
require "active_record"
|
13
|
+
|
14
|
+
Bundler.require(:default, ENV["RAILS_ENV"])
|
15
|
+
|
16
|
+
ActiveSupport::Dependencies.autoload_paths += Dir[ "#{ENV["LAMBDA_TASK_ROOT"]}/app/**/" ]
|
17
|
+
|
18
|
+
Dir["#{ENV["LAMBDA_TASK_ROOT"]}/config/serverless_initializers/*.rb"].each { |file| require file }
|
19
|
+
I18n.load_path << Dir["#{ENV["LAMBDA_TASK_ROOT"]}/config/locales/*.yml"]
|
20
|
+
|
21
|
+
ActiveRecord::Base.configurations = {}
|
22
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV["RAILS_ENV"]])
|
23
|
+
end
|
24
|
+
|
25
|
+
class DefaultApiEntry
|
26
|
+
def self.call(env)
|
27
|
+
status = 200
|
28
|
+
headers = { "Content-Type" => "text/html" }
|
29
|
+
body = ['Hello World.']
|
30
|
+
|
31
|
+
[status, headers, body]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module ServerlessHub
|
36
|
+
module Handler
|
37
|
+
$app ||= Rack::Builder.new do
|
38
|
+
app = begin
|
39
|
+
Kernel.const_get(ENV.fetch('API_ENTRY_CLASS_NAME', 'ApiEntry'))
|
40
|
+
rescue
|
41
|
+
DefaultApiEntry
|
42
|
+
end
|
43
|
+
|
44
|
+
use AuthorizerTokenDecoder
|
45
|
+
use Authorizer
|
46
|
+
run app
|
47
|
+
end.to_app
|
48
|
+
|
49
|
+
def self.call(event: {}, context: {})
|
50
|
+
return "Warm Up" if event["source"] == "serverless-plugin-warmup"
|
51
|
+
|
52
|
+
Lamby.handler $app, event, context, rack: :api
|
53
|
+
rescue Exception => msg
|
54
|
+
p "errors: #{msg}"
|
55
|
+
response = {
|
56
|
+
"statusCode" => 500,
|
57
|
+
"body" => ENV["RAILS_ENV"] == "production" ? "Something wrong happened" : msg,
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
.DS_Store
|
10
|
+
|
11
|
+
# Ignore all logfiles and tempfiles.
|
12
|
+
/log/*
|
13
|
+
/tmp/*
|
14
|
+
!/log/.keep
|
15
|
+
!/tmp/.keep
|
16
|
+
|
17
|
+
/node_modules
|
18
|
+
/yarn-error.log
|
19
|
+
|
20
|
+
.byebug_history
|
21
|
+
/public/packs
|
22
|
+
/public/packs-test
|
23
|
+
/node_modules
|
24
|
+
|
25
|
+
.byebug_history
|
26
|
+
.idea/*
|
27
|
+
vendor/bundle
|
28
|
+
|
29
|
+
# Ignore general setting
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
.env
|
33
|
+
/test/*
|
34
|
+
!/test/mailers
|
35
|
+
/public/packs
|
36
|
+
/public/packs-test
|
37
|
+
yarn-debug.log*
|
38
|
+
.yarn-integrity
|
39
|
+
vendor
|
40
|
+
.serverless
|
41
|
+
lib
|
42
|
+
layer
|
43
|
+
.bundle
|
44
|
+
config.priv.yml
|
45
|
+
node_modules
|
46
|
+
layer
|
47
|
+
node_modules
|
48
|
+
.serverless
|
49
|
+
.byebug_history
|
50
|
+
tmp
|
51
|
+
.env
|
@@ -0,0 +1,54 @@
|
|
1
|
+
const path = require("path")
|
2
|
+
const optimist = require('optimist')
|
3
|
+
const yaml = require("yaml-boost")
|
4
|
+
|
5
|
+
const config = yaml.load(path.join(__dirname, "config/serverless.yml"), optimist.argv)
|
6
|
+
const stage = optimist.argv.stage ? optimist.argv.stage : "dev"
|
7
|
+
|
8
|
+
const layerName = config.service.charAt(0).toUpperCase() + config.service.slice(1) + stage.charAt(0).toUpperCase() + stage.slice(1)
|
9
|
+
const layerStackName = config.service + "-layer-" + stage
|
10
|
+
|
11
|
+
let targetConfig
|
12
|
+
|
13
|
+
if(optimist.argv["stack"] == "layer") {
|
14
|
+
let layers = {}
|
15
|
+
|
16
|
+
layers[layerName] = {
|
17
|
+
path: "layer",
|
18
|
+
description: "Ruby project layer",
|
19
|
+
compatibleRuntimes: ["ruby2.5"]
|
20
|
+
}
|
21
|
+
delete config.provider.environment
|
22
|
+
|
23
|
+
targetConfig = {
|
24
|
+
service: config.service + "-layer",
|
25
|
+
provider: config.provider,
|
26
|
+
layers: layers,
|
27
|
+
package: {
|
28
|
+
include: ["layer/**"]
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
} else {
|
33
|
+
let layerArn = `\${cf:${layerStackName}.` + `${layerName}LambdaLayerQualifiedArn}`.replace(/-/g, 'Dash')
|
34
|
+
|
35
|
+
if(config.custom) {
|
36
|
+
config.custom["layerArn"] = layerArn
|
37
|
+
} else {
|
38
|
+
config.custom = {
|
39
|
+
layerArn: layerArn
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
targetConfig = config
|
44
|
+
}
|
45
|
+
|
46
|
+
if(process.env.CI){
|
47
|
+
if(targetConfig.custom) {
|
48
|
+
delete targetConfig.custom.settings
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
targetConfig.provider["profile"] = "devhub-" + stage
|
52
|
+
}
|
53
|
+
|
54
|
+
module.exports = targetConfig
|
@@ -0,0 +1,44 @@
|
|
1
|
+
service: hello
|
2
|
+
|
3
|
+
custom:
|
4
|
+
settings: ${file(./config/serverless.priv.yml):${self:provider.stage}}
|
5
|
+
|
6
|
+
provider:
|
7
|
+
name: aws
|
8
|
+
runtime: ruby2.5
|
9
|
+
region: ap-southeast-2
|
10
|
+
stage: ${opt:stage, 'dev'}
|
11
|
+
environment:
|
12
|
+
RACK_ENV: production
|
13
|
+
RAILS_ENV: production
|
14
|
+
JWKS_URL: ${env:JWKS_URL, self:custom.settings.jwks_url}
|
15
|
+
DATABASE_URL: ${env:DATABASE_URL, self:custom.settings.database_url}
|
16
|
+
|
17
|
+
package:
|
18
|
+
exclude:
|
19
|
+
- layer/**
|
20
|
+
- node_modules/**
|
21
|
+
- "*.yml"
|
22
|
+
- "*.json"
|
23
|
+
- Dockerfile
|
24
|
+
- db/**
|
25
|
+
- Rakefile
|
26
|
+
- bin/**
|
27
|
+
- log/**
|
28
|
+
- public/**
|
29
|
+
- tmp/**
|
30
|
+
- .gitignore
|
31
|
+
- "*.js"
|
32
|
+
- README.md
|
33
|
+
- config/*.yml
|
34
|
+
- vendor/**
|
35
|
+
|
36
|
+
functions:
|
37
|
+
helloWorld:
|
38
|
+
handler: serverless_hub.ServerlessHub::Handler.call
|
39
|
+
layers:
|
40
|
+
- ${self:custom.layerArn}
|
41
|
+
events:
|
42
|
+
- http:
|
43
|
+
path: hello
|
44
|
+
method: get
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"name": "hello_world",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"description": "##",
|
5
|
+
"private": true,
|
6
|
+
"scripts": {
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
8
|
+
},
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "git@gitlab.devhub.co:DevHubCo/hello_world.git"
|
12
|
+
},
|
13
|
+
"author": "",
|
14
|
+
"license": "ISC",
|
15
|
+
"devDependencies": {
|
16
|
+
"optimist": "^0.6.1",
|
17
|
+
"serverless-domain-manager": "^3.1.0",
|
18
|
+
"serverless-offline": "^4.10.0",
|
19
|
+
"serverless-plugin-warmup": "^4.4.3-rc.1",
|
20
|
+
"yaml-boost": "^1.9.17"
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "serverless_hub/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "m_serverless_hub"
|
8
|
+
spec.version = ServerlessHub::VERSION
|
9
|
+
spec.authors = ["Will"]
|
10
|
+
spec.email = ["will@devhub.co"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://goolge.com.au"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
|
20
|
+
|
21
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
22
|
+
spec.metadata["source_code_uri"] = "https://goolge.com.au"
|
23
|
+
spec.metadata["changelog_uri"] = "https://goolge.com.au"
|
24
|
+
else
|
25
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
26
|
+
"public gem pushes."
|
27
|
+
end
|
28
|
+
|
29
|
+
# Specify which files should be added to the gem when it is released.
|
30
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
31
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
32
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
33
|
+
end
|
34
|
+
spec.bindir = "bin"
|
35
|
+
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
36
|
+
spec.executables = ['serverless_hub']
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency 'bundler', '~> 2.0', '>= 2.0.2'
|
40
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
|
43
|
+
spec.add_runtime_dependency 'json-jwt', '~> 1.11', '>= 1.11.0'
|
44
|
+
spec.add_runtime_dependency 'jwt', '~> 2.1', '>= 2.1.0'
|
45
|
+
spec.add_runtime_dependency 'rest-client', '~> 2.0', '>= 2.0.0'
|
46
|
+
spec.add_runtime_dependency 'lamby', '~> 1.0', '>= 1.0.1'
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: m_serverless_hub
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Will
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-10-28 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: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.0.2
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '13.0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '13.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: json-jwt
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.11'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.11.0
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.11'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.11.0
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: jwt
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '2.1'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 2.1.0
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.1'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 2.1.0
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: rest-client
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '2.0'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.0.0
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.0'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 2.0.0
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: lamby
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '1.0'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 1.0.1
|
131
|
+
type: :runtime
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.0'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 1.0.1
|
141
|
+
description: Write a longer description or delete this line.
|
142
|
+
email:
|
143
|
+
- will@devhub.co
|
144
|
+
executables:
|
145
|
+
- serverless_hub
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- ".gitignore"
|
150
|
+
- ".rspec"
|
151
|
+
- ".ruby-gemset"
|
152
|
+
- ".ruby-version"
|
153
|
+
- ".travis.yml"
|
154
|
+
- Gemfile
|
155
|
+
- Gemfile.lock
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/console
|
159
|
+
- bin/serverless_hub
|
160
|
+
- bin/setup
|
161
|
+
- lib/serverless_hub.rb
|
162
|
+
- lib/serverless_hub/authorizer.rb
|
163
|
+
- lib/serverless_hub/handler.rb
|
164
|
+
- lib/serverless_hub/templates/gitignore
|
165
|
+
- lib/serverless_hub/templates/serverless.js
|
166
|
+
- lib/serverless_hub/templates/serverless/Dockerfile
|
167
|
+
- lib/serverless_hub/templates/serverless/config/serverless.priv.yml
|
168
|
+
- lib/serverless_hub/templates/serverless/config/serverless.yml
|
169
|
+
- lib/serverless_hub/templates/serverless/package.json
|
170
|
+
- lib/serverless_hub/version.rb
|
171
|
+
- m_serverless_hub.gemspec
|
172
|
+
homepage: https://goolge.com.au
|
173
|
+
licenses: []
|
174
|
+
metadata:
|
175
|
+
homepage_uri: https://goolge.com.au
|
176
|
+
source_code_uri: https://goolge.com.au
|
177
|
+
changelog_uri: https://goolge.com.au
|
178
|
+
post_install_message:
|
179
|
+
rdoc_options: []
|
180
|
+
require_paths:
|
181
|
+
- lib
|
182
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - ">="
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
|
+
requirements:
|
189
|
+
- - ">="
|
190
|
+
- !ruby/object:Gem::Version
|
191
|
+
version: '0'
|
192
|
+
requirements: []
|
193
|
+
rubyforge_project:
|
194
|
+
rubygems_version: 2.7.6.2
|
195
|
+
signing_key:
|
196
|
+
specification_version: 4
|
197
|
+
summary: Write a short summary, because RubyGems requires one.
|
198
|
+
test_files: []
|