lamby 2.5.3 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/lamby/handler.rb +8 -0
- data/lib/lamby/rack_alb.rb +4 -1
- data/lib/lamby/rack_http.rb +12 -0
- data/lib/lamby/rack_rest.rb +5 -0
- data/lib/lamby/templates/alb/_deploy +14 -4
- data/lib/lamby/templates/alb/deploy +4 -0
- data/lib/lamby/templates/http/_deploy +14 -4
- data/lib/lamby/templates/http/deploy +4 -0
- data/lib/lamby/templates/rest/_deploy +14 -4
- data/lib/lamby/templates/rest/deploy +4 -0
- data/lib/lamby/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d9a016b7bcfeb2c05897068c0f4bae484e1769331da8687e1caf743a7acd55a
|
4
|
+
data.tar.gz: 0cf5b19f4db83a839aaa64e7f498395803c926cb1088f00779dc02a504211268
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ec3d030577596053e61a85c9e3d64917e06caab8b7119a6fcf3bba4d4ba787804e8ebdfa0c175b1925b61ef25c9026eca5989c93c61637b2db89fdaca4f74c
|
7
|
+
data.tar.gz: cc7ea0e3b008d694e144f19abdc373b623c80f1df7c8369dee997e0ca3b1ddea98cfb78ecb9836418653d02670604a2d548f38d371d9ac6f80aaf70b088749ba
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/lamby/handler.rb
CHANGED
@@ -31,6 +31,13 @@ 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
43
|
@body.each { |part| rbody << part }
|
@@ -40,6 +47,7 @@ module Lamby
|
|
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
|
data/lib/lamby/rack_alb.rb
CHANGED
@@ -11,7 +11,10 @@ module Lamby
|
|
11
11
|
|
12
12
|
def response(handler)
|
13
13
|
hhdrs = handler.headers
|
14
|
-
|
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
19
|
base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
|
17
20
|
body = Base64.strict_encode64(handler.body) if base64_encode
|
data/lib/lamby/rack_http.rb
CHANGED
@@ -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
|
data/lib/lamby/rack_rest.rb
CHANGED
@@ -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.$
|
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
|
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 "
|
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 "
|
56
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
47
57
|
--image-repository "$IMAGE_REPOSITORY" \
|
48
58
|
--capabilities "CAPABILITY_IAM" \
|
49
59
|
--parameter-overrides \
|
@@ -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.$
|
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
|
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 "
|
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 "
|
41
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
32
42
|
--image-repository "$IMAGE_REPOSITORY" \
|
33
43
|
--capabilities "CAPABILITY_IAM" \
|
34
44
|
--parameter-overrides \
|
@@ -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.$
|
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
|
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 "
|
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 "
|
41
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
32
42
|
--image-repository "$IMAGE_REPOSITORY" \
|
33
43
|
--capabilities "CAPABILITY_IAM" \
|
34
44
|
--parameter-overrides \
|
data/lib/lamby/version.rb
CHANGED
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.
|
4
|
+
version: 2.6.0
|
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-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|