lamby 2.5.2 → 2.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0051a75ff0e51b92b660dcab7697dcc015824f01a5e5bbbdca960f749da197c
4
- data.tar.gz: 45da42505df9c282cffc4097739c3b7278b9d95057675860e1044d73036d7b2b
3
+ metadata.gz: 36a979a80914b8e2b6b15bc65e5a2de4e2ee42021702dc194ded907697f05737
4
+ data.tar.gz: e1dab7496ce709072a0a7d41fcd1c3e3bb7c9195b33cef868310650d82a06e26
5
5
  SHA512:
6
- metadata.gz: af98da487e7fd90fa68f547cb92040e21bae77c3049e4f83e93b436e0455312bfef1ea1cd976b74ad76e74f16d3e5c3b0cb47c8ed6d41ffd52ce072303cc9bb0
7
- data.tar.gz: 6531ffcc4f0bb7268b3e1c4c7be5c0a6a2e54966def1570f40bd7fb53336c0c22b21f17b77f3caab8b436b0abbb460654d49076760614ab98f77270fa828d51f
6
+ metadata.gz: 2340052e5aa0926d2e096cd0db6fed6f7085243f1caf404b40d570f94cd4bd1b28d608749fe78334c8af97fcf218263f745607aba2c84ac593e0d13da3dd3945
7
+ data.tar.gz: 1b5b4dc67b81ee9c0ad905256cd9d43a105a41efc93661920b52d4b184836a39222079fd971a5379b75a2ae31b8cfefe6fa6d2bc04c3d5afe1a3d4252acd5915
data/CHANGELOG.md CHANGED
@@ -1,61 +1,94 @@
1
1
  <!-- -*- mode: markdown -*- -->
2
+
2
3
  # Keep A Changelog!
3
4
 
4
5
  See this http://keepachangelog.com link for information on how we want this documented formatted.
5
6
 
7
+ ## v2.6.3
8
+
9
+ #### Added
10
+
11
+ - Bootsnap setup convenience require.
12
+
13
+ ## v2.6.2
14
+
15
+ - Fixed Rack::Deflate usage with an ALB.
16
+
17
+ ## v2.6.1
18
+
19
+ #### Fixed
20
+
21
+ - Support redirects with empty response body.
22
+
23
+ #### Added
24
+
25
+ - Tests for enabling Rack::Deflate middleware by passing RACK_DEFLATE_ENABLED env variable.
26
+
27
+ ## v2.6.0
28
+
29
+ #### Fixed
30
+
31
+ - Support multiple Set-Cookie headers for all rest types.
32
+
33
+ ## v2.5.3
34
+
35
+ #### Fixed
36
+
37
+ - Base64 encode response body if the rack response is gzip or brotli compressed.
38
+
6
39
  ## v2.5.2
7
40
 
8
- * SSM file always overwrites. Fixes #65.
41
+ - SSM file always overwrites. Fixes #65.
9
42
 
10
43
  ## v2.5.1
11
44
 
12
45
  #### Fixed
13
46
 
14
- * Quoting in describe-subnets #62 Thanks @atwoodjw
47
+ - Quoting in describe-subnets #62 Thanks @atwoodjw
15
48
 
16
49
  ## v2.5.0
17
50
 
18
51
  #### Changed
19
52
 
20
- * Install files to favor containers.
53
+ - Install files to favor containers.
21
54
 
22
55
  ## v2.2.2
23
56
 
24
57
  #### Changed
25
58
 
26
- * More ActiveSupport removal. Better ENV.to_h.
59
+ - More ActiveSupport removal. Better ENV.to_h.
27
60
 
28
61
  ## v2.2.1
29
62
 
30
63
  #### Changed
31
64
 
32
- * More ActiveSupport removal from SsmParameterStore.
65
+ - More ActiveSupport removal from SsmParameterStore.
33
66
 
34
67
  ## v2.2.0
35
68
 
36
69
  #### Changed
37
70
 
38
- * Remove dependency on `activesupport` for rack-only applications.
39
- * Remove ActiveSupport artifacts:
71
+ - Remove dependency on `activesupport` for rack-only applications.
72
+ - Remove ActiveSupport artifacts:
40
73
  - Replace `strip_heredoc` with `<<~HEREDOC`.
41
74
  - Remove instances of `Object#try`, replace with `&.`.
42
75
  - Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
43
76
  - Replace `Object#present?` with `to_s.empty?`.
44
77
  - Replace `Array.wrap` with `Array[obj].compact.flatten`.
45
- * Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
78
+ - Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
46
79
  variables prior to enabling debug mode.
47
80
 
48
81
  ## v2.1.0
49
82
 
50
83
  #### Changed
51
84
 
52
- * Only load the railtie if `Rails` is defined.
85
+ - Only load the railtie if `Rails` is defined.
53
86
 
54
87
  ## v2.0.1
55
88
 
56
89
  #### Changed
57
90
 
58
- * Remove Rails runtime dep. Only rack is needed.
91
+ - Remove Rails runtime dep. Only rack is needed.
59
92
 
60
93
  ## v2.0.0
61
94
 
@@ -63,120 +96,107 @@ Support for new API Gateway HTTP APIs!!!
63
96
 
64
97
  #### Changed
65
98
 
66
- * The `Lamby.handler` must have a `:rack` option. One of `:http`, `:rest`, `:alb`.
67
- * Renamed template generators to match options above.
68
- * The `lamby:install` task now defaults to HTTP API.
69
- * Changed the name of `:api` rack option to `:rest`.
70
- * Removed `export` from Dotenv files. Better Docker compatability.
99
+ - The `Lamby.handler` must have a `:rack` option. One of `:http`, `:rest`, `:alb`.
100
+ - Renamed template generators to match options above.
101
+ - The `lamby:install` task now defaults to HTTP API.
102
+ - Changed the name of `:api` rack option to `:rest`.
103
+ - Removed `export` from Dotenv files. Better Docker compatability.
71
104
 
72
105
  #### Added
73
106
 
74
- * New rack handler for HTTP API v1 and v2.
75
- * Lots of backfill tests for, ALBs & REST APIs.
76
-
107
+ - New rack handler for HTTP API v1 and v2.
108
+ - Lots of backfill tests for, ALBs & REST APIs.
77
109
 
78
110
  ## v1.0.3
79
111
 
80
112
  #### Changed
81
113
 
82
- * Change shebangs to `#!/usr/bin/env bash`
83
-
114
+ - Change shebangs to `#!/usr/bin/env bash`
84
115
 
85
116
  ## v1.0.2
86
117
 
87
118
  #### Changed
88
119
 
89
- * Adds an optional 'overwrite' parameter to #to_env.
120
+ - Adds an optional 'overwrite' parameter to #to_env.
90
121
 
91
122
  ## v1.0.1
92
123
 
93
124
  #### Changed
94
125
 
95
- * Links in bin/build templates to point to lamby.custominktech.com site.
96
-
126
+ - Links in bin/build templates to point to lamby.custominktech.com site.
97
127
 
98
128
  ## v1.0.0
99
129
 
100
130
  #### Fixed
101
131
 
102
- * ALB query params & binary responses. Fixes #38.
103
-
132
+ - ALB query params & binary responses. Fixes #38.
104
133
 
105
134
  ## v0.6.0
106
135
 
107
136
  #### Added
108
137
 
109
- * APPLICATION LOAD BALANACER SUPPORT!!! The new default. Use `rack: :api` option to handler for API Gateway support.
138
+ - APPLICATION LOAD BALANACER SUPPORT!!! The new default. Use `rack: :api` option to handler for API Gateway support.
110
139
 
111
140
  #### Changed
112
141
 
113
- * Rake task `lamby:install` now defaults to `application_load_balancer`
114
-
142
+ - Rake task `lamby:install` now defaults to `application_load_balancer`
115
143
 
116
144
  ## v0.5.1
117
145
 
118
146
  #### Fixed
119
147
 
120
- * The .gitignore file template. Fix .aws-sam dir.
121
-
148
+ - The .gitignore file template. Fix .aws-sam dir.
122
149
 
123
150
  ## v0.5.0
124
151
 
125
152
  #### Added
126
153
 
127
- * Template generators for first install. Ex: `./bin/rake -r lamby lamby:install:api_gateway`.
128
- * New `Lamby::SsmParameterStore.get!` helper.
129
-
154
+ - Template generators for first install. Ex: `./bin/rake -r lamby lamby:install:api_gateway`.
155
+ - New `Lamby::SsmParameterStore.get!` helper.
130
156
 
131
157
  ## v0.4.1
132
158
 
133
159
  #### Fixed
134
160
 
135
- * Fix type in v0.4.0 fix below.
136
-
161
+ - Fix type in v0.4.0 fix below.
137
162
 
138
163
  ## v0.4.0
139
164
 
140
165
  #### Fixed
141
166
 
142
- * File uploads in #33 using `CONTENT_TYPE` and `CONTENT_LENGTH`.
143
-
167
+ - File uploads in #33 using `CONTENT_TYPE` and `CONTENT_LENGTH`.
144
168
 
145
169
  ## v0.3.2
146
170
 
147
171
  #### Added
148
172
 
149
- * Pass Request ID for CloudWatch logs. Fixes #30.
150
-
173
+ - Pass Request ID for CloudWatch logs. Fixes #30.
151
174
 
152
175
  ## v0.3.1
153
176
 
154
177
  #### Changed
155
178
 
156
- * Docs and SAM template tweaks.
157
-
179
+ - Docs and SAM template tweaks.
158
180
 
159
181
  ## v0.3.0
160
182
 
161
183
  #### Added
162
184
 
163
- * Secure configs rake task.
164
- * Project bin setup and tests.
185
+ - Secure configs rake task.
186
+ - Project bin setup and tests.
165
187
 
166
188
  #### Changed
167
189
 
168
- * SAM template tweaks.
169
-
190
+ - SAM template tweaks.
170
191
 
171
192
  ## v0.2.0
172
193
 
173
194
  #### Changed
174
195
 
175
- * Simple docs and project re-organization.
176
-
196
+ - Simple docs and project re-organization.
177
197
 
178
198
  ## v0.1.0
179
199
 
180
200
  #### Added
181
201
 
182
- * New gem and placeholder in rubygems.
202
+ - New gem and placeholder in rubygems.
data/Dockerfile CHANGED
@@ -1,10 +1,5 @@
1
1
  FROM lambci/lambda:build-ruby2.7
2
2
 
3
- # Lock down AWS SAM version.
4
- RUN pip install awscli && \
5
- pip uninstall --yes aws-sam-cli && \
6
- pip install aws-sam-cli==0.45.0
7
-
8
3
  # Asset Pipeline
9
4
  RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
10
5
  yum install -y nodejs
data/Gemfile.lock CHANGED
@@ -1,155 +1,158 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lamby (2.5.2)
4
+ lamby (2.6.3)
5
5
  rack
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (6.0.2.2)
11
- actionpack (= 6.0.2.2)
10
+ actioncable (6.1.3.1)
11
+ actionpack (= 6.1.3.1)
12
+ activesupport (= 6.1.3.1)
12
13
  nio4r (~> 2.0)
13
14
  websocket-driver (>= 0.6.1)
14
- actionmailbox (6.0.2.2)
15
- actionpack (= 6.0.2.2)
16
- activejob (= 6.0.2.2)
17
- activerecord (= 6.0.2.2)
18
- activestorage (= 6.0.2.2)
19
- activesupport (= 6.0.2.2)
15
+ actionmailbox (6.1.3.1)
16
+ actionpack (= 6.1.3.1)
17
+ activejob (= 6.1.3.1)
18
+ activerecord (= 6.1.3.1)
19
+ activestorage (= 6.1.3.1)
20
+ activesupport (= 6.1.3.1)
20
21
  mail (>= 2.7.1)
21
- actionmailer (6.0.2.2)
22
- actionpack (= 6.0.2.2)
23
- actionview (= 6.0.2.2)
24
- activejob (= 6.0.2.2)
22
+ actionmailer (6.1.3.1)
23
+ actionpack (= 6.1.3.1)
24
+ actionview (= 6.1.3.1)
25
+ activejob (= 6.1.3.1)
26
+ activesupport (= 6.1.3.1)
25
27
  mail (~> 2.5, >= 2.5.4)
26
28
  rails-dom-testing (~> 2.0)
27
- actionpack (6.0.2.2)
28
- actionview (= 6.0.2.2)
29
- activesupport (= 6.0.2.2)
30
- rack (~> 2.0, >= 2.0.8)
29
+ actionpack (6.1.3.1)
30
+ actionview (= 6.1.3.1)
31
+ activesupport (= 6.1.3.1)
32
+ rack (~> 2.0, >= 2.0.9)
31
33
  rack-test (>= 0.6.3)
32
34
  rails-dom-testing (~> 2.0)
33
35
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
- actiontext (6.0.2.2)
35
- actionpack (= 6.0.2.2)
36
- activerecord (= 6.0.2.2)
37
- activestorage (= 6.0.2.2)
38
- activesupport (= 6.0.2.2)
36
+ actiontext (6.1.3.1)
37
+ actionpack (= 6.1.3.1)
38
+ activerecord (= 6.1.3.1)
39
+ activestorage (= 6.1.3.1)
40
+ activesupport (= 6.1.3.1)
39
41
  nokogiri (>= 1.8.5)
40
- actionview (6.0.2.2)
41
- activesupport (= 6.0.2.2)
42
+ actionview (6.1.3.1)
43
+ activesupport (= 6.1.3.1)
42
44
  builder (~> 3.1)
43
45
  erubi (~> 1.4)
44
46
  rails-dom-testing (~> 2.0)
45
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
- activejob (6.0.2.2)
47
- activesupport (= 6.0.2.2)
48
+ activejob (6.1.3.1)
49
+ activesupport (= 6.1.3.1)
48
50
  globalid (>= 0.3.6)
49
- activemodel (6.0.2.2)
50
- activesupport (= 6.0.2.2)
51
- activerecord (6.0.2.2)
52
- activemodel (= 6.0.2.2)
53
- activesupport (= 6.0.2.2)
54
- activestorage (6.0.2.2)
55
- actionpack (= 6.0.2.2)
56
- activejob (= 6.0.2.2)
57
- activerecord (= 6.0.2.2)
58
- marcel (~> 0.3.1)
59
- activesupport (6.0.2.2)
51
+ activemodel (6.1.3.1)
52
+ activesupport (= 6.1.3.1)
53
+ activerecord (6.1.3.1)
54
+ activemodel (= 6.1.3.1)
55
+ activesupport (= 6.1.3.1)
56
+ activestorage (6.1.3.1)
57
+ actionpack (= 6.1.3.1)
58
+ activejob (= 6.1.3.1)
59
+ activerecord (= 6.1.3.1)
60
+ activesupport (= 6.1.3.1)
61
+ marcel (~> 1.0.0)
62
+ mini_mime (~> 1.0.2)
63
+ activesupport (6.1.3.1)
60
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
61
- i18n (>= 0.7, < 2)
62
- minitest (~> 5.1)
63
- tzinfo (~> 1.1)
64
- zeitwerk (~> 2.2)
65
- aws-eventstream (1.0.3)
66
- aws-partitions (1.287.0)
67
- aws-sdk-core (3.92.0)
68
- aws-eventstream (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ aws-eventstream (1.1.1)
70
+ aws-partitions (1.446.0)
71
+ aws-sdk-core (3.114.0)
72
+ aws-eventstream (~> 1, >= 1.0.2)
69
73
  aws-partitions (~> 1, >= 1.239.0)
70
74
  aws-sigv4 (~> 1.1)
71
75
  jmespath (~> 1.0)
72
- aws-sdk-ssm (1.73.0)
73
- aws-sdk-core (~> 3, >= 3.71.0)
76
+ aws-sdk-ssm (1.108.0)
77
+ aws-sdk-core (~> 3, >= 3.112.0)
74
78
  aws-sigv4 (~> 1.1)
75
- aws-sigv4 (1.1.1)
76
- aws-eventstream (~> 1.0, >= 1.0.2)
79
+ aws-sigv4 (1.2.3)
80
+ aws-eventstream (~> 1, >= 1.0.2)
77
81
  builder (3.2.4)
78
- coderay (1.1.2)
79
- concurrent-ruby (1.1.6)
82
+ coderay (1.1.3)
83
+ concurrent-ruby (1.1.8)
80
84
  crass (1.0.6)
81
- erubi (1.9.0)
85
+ erubi (1.10.0)
82
86
  globalid (0.4.2)
83
87
  activesupport (>= 4.2.0)
84
- i18n (1.8.2)
88
+ i18n (1.8.10)
85
89
  concurrent-ruby (~> 1.0)
86
90
  jmespath (1.4.0)
87
- loofah (2.4.0)
91
+ loofah (2.9.1)
88
92
  crass (~> 1.0.2)
89
93
  nokogiri (>= 1.5.9)
90
94
  mail (2.7.1)
91
95
  mini_mime (>= 0.1.1)
92
- marcel (0.3.3)
93
- mimemagic (~> 0.3.2)
96
+ marcel (1.0.1)
94
97
  method_source (1.0.0)
95
- mimemagic (0.3.4)
96
- mini_mime (1.0.2)
97
- mini_portile2 (2.4.0)
98
- minitest (5.14.0)
99
- minitest-focus (1.1.2)
98
+ mini_mime (1.0.3)
99
+ mini_portile2 (2.5.0)
100
+ minitest (5.14.4)
101
+ minitest-focus (1.2.1)
100
102
  minitest (>= 4, < 6)
101
- mocha (1.11.2)
102
- nio4r (2.5.2)
103
- nokogiri (1.10.9)
104
- mini_portile2 (~> 2.4.0)
105
- pry (0.13.0)
103
+ mocha (1.12.0)
104
+ nio4r (2.5.7)
105
+ nokogiri (1.11.3)
106
+ mini_portile2 (~> 2.5.0)
107
+ racc (~> 1.4)
108
+ pry (0.14.1)
106
109
  coderay (~> 1.1)
107
110
  method_source (~> 1.0)
108
- rack (2.2.2)
111
+ racc (1.5.2)
112
+ rack (2.2.3)
109
113
  rack-test (1.1.0)
110
114
  rack (>= 1.0, < 3)
111
- rails (6.0.2.2)
112
- actioncable (= 6.0.2.2)
113
- actionmailbox (= 6.0.2.2)
114
- actionmailer (= 6.0.2.2)
115
- actionpack (= 6.0.2.2)
116
- actiontext (= 6.0.2.2)
117
- actionview (= 6.0.2.2)
118
- activejob (= 6.0.2.2)
119
- activemodel (= 6.0.2.2)
120
- activerecord (= 6.0.2.2)
121
- activestorage (= 6.0.2.2)
122
- activesupport (= 6.0.2.2)
123
- bundler (>= 1.3.0)
124
- railties (= 6.0.2.2)
115
+ rails (6.1.3.1)
116
+ actioncable (= 6.1.3.1)
117
+ actionmailbox (= 6.1.3.1)
118
+ actionmailer (= 6.1.3.1)
119
+ actionpack (= 6.1.3.1)
120
+ actiontext (= 6.1.3.1)
121
+ actionview (= 6.1.3.1)
122
+ activejob (= 6.1.3.1)
123
+ activemodel (= 6.1.3.1)
124
+ activerecord (= 6.1.3.1)
125
+ activestorage (= 6.1.3.1)
126
+ activesupport (= 6.1.3.1)
127
+ bundler (>= 1.15.0)
128
+ railties (= 6.1.3.1)
125
129
  sprockets-rails (>= 2.0.0)
126
130
  rails-dom-testing (2.0.3)
127
131
  activesupport (>= 4.2.0)
128
132
  nokogiri (>= 1.6)
129
133
  rails-html-sanitizer (1.3.0)
130
134
  loofah (~> 2.3)
131
- railties (6.0.2.2)
132
- actionpack (= 6.0.2.2)
133
- activesupport (= 6.0.2.2)
135
+ railties (6.1.3.1)
136
+ actionpack (= 6.1.3.1)
137
+ activesupport (= 6.1.3.1)
134
138
  method_source
135
139
  rake (>= 0.8.7)
136
- thor (>= 0.20.3, < 2.0)
137
- rake (13.0.1)
138
- sprockets (4.0.0)
140
+ thor (~> 1.0)
141
+ rake (13.0.3)
142
+ sprockets (4.0.2)
139
143
  concurrent-ruby (~> 1.0)
140
144
  rack (> 1, < 3)
141
- sprockets-rails (3.2.1)
145
+ sprockets-rails (3.2.2)
142
146
  actionpack (>= 4.0)
143
147
  activesupport (>= 4.0)
144
148
  sprockets (>= 3.0.0)
145
- thor (1.0.1)
146
- thread_safe (0.3.6)
147
- tzinfo (1.2.6)
148
- thread_safe (~> 0.1)
149
- websocket-driver (0.7.1)
149
+ thor (1.1.0)
150
+ tzinfo (2.0.4)
151
+ concurrent-ruby (~> 1.0)
152
+ websocket-driver (0.7.3)
150
153
  websocket-extensions (>= 0.1.0)
151
- websocket-extensions (0.1.4)
152
- zeitwerk (2.3.0)
154
+ websocket-extensions (0.1.5)
155
+ zeitwerk (2.4.2)
153
156
 
154
157
  PLATFORMS
155
158
  ruby
@@ -166,4 +169,4 @@ DEPENDENCIES
166
169
  rake
167
170
 
168
171
  BUNDLED WITH
169
- 2.1.4
172
+ 2.2.15
data/Rakefile CHANGED
@@ -10,4 +10,12 @@ Rake::TestTask.new(:test) do |t|
10
10
  t.warning = false
11
11
  end
12
12
 
13
- task :default => :test
13
+ Rake::TestTask.new(:test_deflate) do |t|
14
+ t.libs << "test"
15
+ t.libs << "lib"
16
+ t.test_files = FileList["test/rack_deflate_test.rb"]
17
+ t.verbose = false
18
+ t.warning = false
19
+ end
20
+
21
+ task :default => [:test, :test_deflate]
data/bin/_test CHANGED
@@ -4,3 +4,4 @@ set -e
4
4
  export RAILS_ENV="test"
5
5
 
6
6
  bundle exec rake test
7
+ RACK_DEFLATE_ENABLED=1 bundle exec rake test_deflate
@@ -0,0 +1,8 @@
1
+ unless ENV['LAMBY_BOOTSNAP_PRECOMPILE']
2
+ require 'bootsnap'
3
+ Bootsnap::LoadPathCache::Store.class_eval do
4
+ def commit_transaction ; end
5
+ end
6
+ end
7
+ require 'bootsnap/bootsnap' # https://git.io/JOSzG
8
+ require 'bootsnap/setup'
data/lib/lamby/handler.rb CHANGED
@@ -31,23 +31,32 @@ module Lamby
31
31
  @headers
32
32
  end
33
33
 
34
+ def set_cookies
35
+ return @set_cookies if defined?(@set_cookies)
36
+ @set_cookies = if @headers && @headers['Set-Cookie']
37
+ @headers.delete('Set-Cookie').split("\n")
38
+ end
39
+ end
40
+
34
41
  def body
35
42
  @rbody ||= ''.tap do |rbody|
36
- @body.each { |part| rbody << part }
43
+ @body.each { |part| rbody << part if part }
37
44
  end
38
45
  end
39
46
 
40
47
  def call
41
48
  return self if @called
42
49
  @status, @headers, @body = call_app
50
+ set_cookies
43
51
  @called = true
44
52
  self
45
53
  end
46
54
 
47
- def base64_encodeable?
48
- @headers && (
49
- @headers['Content-Transfer-Encoding'] == 'binary' ||
50
- @headers['X-Lamby-Base64'] == '1'
55
+ def base64_encodeable?(hdrs = @headers)
56
+ hdrs && (
57
+ hdrs['Content-Transfer-Encoding'] == 'binary' ||
58
+ content_encoding_compressed?(hdrs) ||
59
+ hdrs['X-Lamby-Base64'] == '1'
51
60
  )
52
61
  end
53
62
 
@@ -80,5 +89,9 @@ module Lamby
80
89
  end
81
90
  end
82
91
 
92
+ def content_encoding_compressed?(hdrs)
93
+ content_encoding_header = hdrs['Content-Encoding'] || ''
94
+ content_encoding_header.split(', ').any? { |h| ['br', 'gzip'].include?(h) }
95
+ end
83
96
  end
84
97
  end
@@ -11,9 +11,12 @@ module Lamby
11
11
 
12
12
  def response(handler)
13
13
  hhdrs = handler.headers
14
- multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten } if multi_value?
14
+ if multi_value?
15
+ multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten }
16
+ multivalue_headers['Set-Cookie'] = handler.set_cookies if handler.set_cookies
17
+ end
15
18
  status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
16
- base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
19
+ base64_encode = handler.base64_encodeable?(hhdrs)
17
20
  body = Base64.strict_encode64(handler.body) if base64_encode
18
21
  { multiValueHeaders: multivalue_headers,
19
22
  statusDescription: status_description,
@@ -6,6 +6,15 @@ module Lamby
6
6
  { isBase64Encoded: true, body: handler.body64 }
7
7
  else
8
8
  super
9
+ end.tap do |r|
10
+ if cookies = handler.set_cookies
11
+ if payload_version_one?
12
+ r[:multiValueHeaders] ||= {}
13
+ r[:multiValueHeaders]['Set-Cookie'] = cookies
14
+ else
15
+ r[:cookies] = cookies
16
+ end
17
+ end
9
18
  end
10
19
  end
11
20
 
@@ -79,6 +88,9 @@ module Lamby
79
88
  'HTTP/1.1'
80
89
  end
81
90
 
91
+ def payload_version_one?
92
+ event['version'] == '1.0'
93
+ end
82
94
 
83
95
  end
84
96
  end
@@ -6,6 +6,11 @@ module Lamby
6
6
  { isBase64Encoded: true, body: handler.body64 }
7
7
  else
8
8
  super
9
+ end.tap do |r|
10
+ if cookies = handler.set_cookies
11
+ r[:multiValueHeaders] ||= {}
12
+ r[:multiValueHeaders]['Set-Cookie'] = cookies
13
+ end
9
14
  end
10
15
  end
11
16
 
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  export VPCID=${VPCID:=$(
@@ -37,13 +47,13 @@ sam package \
37
47
  --output-template-file ./.aws-sam/build/packaged.yaml \
38
48
  --image-repository "$IMAGE_REPOSITORY" \
39
49
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
40
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
50
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
41
51
 
42
52
  echo "== SAM deploy..."
43
53
  sam deploy \
44
54
  --region "$AWS_DEFAULT_REGION" \
45
55
  --template-file ./.aws-sam/build/packaged.yaml \
46
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
56
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
47
57
  --image-repository "$IMAGE_REPOSITORY" \
48
58
  --capabilities "CAPABILITY_IAM" \
49
59
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  sam build \
@@ -22,13 +32,13 @@ sam package \
22
32
  --output-template-file ./.aws-sam/build/packaged.yaml \
23
33
  --image-repository "$IMAGE_REPOSITORY" \
24
34
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
25
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
35
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
26
36
 
27
37
  echo "== SAM deploy..."
28
38
  sam deploy \
29
39
  --region "$AWS_DEFAULT_REGION" \
30
40
  --template-file ./.aws-sam/build/packaged.yaml \
31
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
41
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
32
42
  --image-repository "$IMAGE_REPOSITORY" \
33
43
  --capabilities "CAPABILITY_IAM" \
34
44
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
@@ -1,14 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
  set -e
3
3
 
4
+ export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
4
5
  export RAILS_ENV=${RAILS_ENV:="production"}
5
6
  export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
6
- export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
7
+ export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
7
8
 
8
9
  # https://github.com/aws/aws-sam-cli/issues/2447
9
10
  export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
10
- export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/myorg/APPNAMEHERE"
11
+ export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
11
12
 
13
+ echo '== Creating ECR repository =='
14
+ echo 'You can safely ignore any RepositoryAlreadyExistsException errors...'
15
+ aws ecr create-repository \
16
+ --repository-name "$DEPLOYMENT_NAME" \
17
+ --image-tag-mutability MUTABLE \
18
+ --image-scanning-configuration scanOnPush=true \
19
+ --region "$AWS_DEFAULT_REGION" || true
20
+
21
+ # Build our application code into a deployment folder
12
22
  ./bin/_build
13
23
 
14
24
  sam build \
@@ -22,13 +32,13 @@ sam package \
22
32
  --output-template-file ./.aws-sam/build/packaged.yaml \
23
33
  --image-repository "$IMAGE_REPOSITORY" \
24
34
  --s3-bucket "${CLOUDFORMATION_BUCKET}" \
25
- --s3-prefix "APPNAMEHERE-${RAILS_ENV}"
35
+ --s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
26
36
 
27
37
  echo "== SAM deploy..."
28
38
  sam deploy \
29
39
  --region "$AWS_DEFAULT_REGION" \
30
40
  --template-file ./.aws-sam/build/packaged.yaml \
31
- --stack-name "APPNAMEHERE-${RAILS_ENV}" \
41
+ --stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
32
42
  --image-repository "$IMAGE_REPOSITORY" \
33
43
  --capabilities "CAPABILITY_IAM" \
34
44
  --parameter-overrides \
@@ -3,6 +3,10 @@ set -e
3
3
 
4
4
  export RAILS_ENV=${RAILS_ENV:=production}
5
5
 
6
+ if [[ "$OSTYPE" == *"darwin"* ]]; then
7
+ export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
8
+ fi
9
+
6
10
  docker-compose run \
7
11
  -e CLOUDFORMATION_BUCKET \
8
12
  cicd \
data/lib/lamby/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lamby
2
- VERSION = '2.5.2'
2
+ VERSION = '2.6.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lamby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Collins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-28 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -150,6 +150,7 @@ files:
150
150
  - docker-compose.yml
151
151
  - lamby.gemspec
152
152
  - lib/lamby.rb
153
+ - lib/lamby/bootsnap.rb
153
154
  - lib/lamby/debug.rb
154
155
  - lib/lamby/handler.rb
155
156
  - lib/lamby/logger.rb