lamby 2.0.1 → 2.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +40 -1
- data/Gemfile.lock +1 -1
- data/lib/lamby.rb +5 -3
- data/lib/lamby/debug.rb +8 -1
- data/lib/lamby/rack.rb +11 -1
- data/lib/lamby/rack_alb.rb +1 -1
- data/lib/lamby/rack_http.rb +6 -2
- data/lib/lamby/ssm_parameter_store.rb +7 -6
- data/lib/lamby/templates/alb.rb +11 -3
- data/lib/lamby/templates/alb/Dockerfile +3 -0
- data/lib/lamby/templates/alb/Dockerfile-build +15 -0
- data/lib/lamby/templates/alb/_build +40 -0
- data/lib/lamby/templates/alb/_deploy +52 -0
- data/lib/lamby/templates/alb/app.rb +2 -0
- data/lib/lamby/templates/alb/deploy +5 -35
- data/lib/lamby/templates/alb/docker-compose.yml +17 -0
- data/lib/lamby/templates/alb/template.yaml +11 -11
- data/lib/lamby/templates/http.rb +11 -3
- data/lib/lamby/templates/http/Dockerfile +3 -0
- data/lib/lamby/templates/http/Dockerfile-build +15 -0
- data/lib/lamby/templates/http/_build +40 -0
- data/lib/lamby/templates/http/_deploy +35 -0
- data/lib/lamby/templates/http/app.rb +2 -0
- data/lib/lamby/templates/http/deploy +5 -18
- data/lib/lamby/templates/http/docker-compose.yml +17 -0
- data/lib/lamby/templates/http/template.yaml +7 -7
- data/lib/lamby/templates/rest.rb +11 -3
- data/lib/lamby/templates/rest/Dockerfile +3 -0
- data/lib/lamby/templates/rest/Dockerfile-build +15 -0
- data/lib/lamby/templates/rest/_build +40 -0
- data/lib/lamby/templates/rest/_deploy +35 -0
- data/lib/lamby/templates/rest/app.rb +2 -0
- data/lib/lamby/templates/rest/deploy +5 -18
- data/lib/lamby/templates/rest/docker-compose.yml +17 -0
- data/lib/lamby/templates/rest/template.yaml +9 -9
- data/lib/lamby/version.rb +1 -1
- metadata +17 -5
- data/lib/lamby/templates/alb/build +0 -23
- data/lib/lamby/templates/http/build +0 -23
- data/lib/lamby/templates/rest/build +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8846dc8b26074a2887d0f5d0a605cd19345c4f1c5d36e2be5f856606c95f12e
|
4
|
+
data.tar.gz: 2251ce4c68c2e7d1160f1917cce9e858dab4e19d068edcaf310e997ac698d2ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 197fb20357ba00b1dd50a2c2ef6a6804532a861afe9fa2ae4490c1fa1d5ea8648e02ba505070afc06f96051a913ae89f2a1403c41e3750ac96d8af239468d633
|
7
|
+
data.tar.gz: 258e6f51dbc28f483286068e2b749a843e50a082fc18a198bf5242f27b509eb93f845bf06ab4bd49b2a6daacb00759794b77fd4b88991f088ce8ae59d38427f9
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,46 @@
|
|
1
|
+
<!-- -*- mode: markdown -*- -->
|
1
2
|
# Keep A Changelog!
|
2
3
|
|
3
4
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
4
5
|
|
6
|
+
## v2.5.0
|
7
|
+
|
8
|
+
#### Changed
|
9
|
+
|
10
|
+
* Install files to favor containers.
|
11
|
+
|
12
|
+
## v2.2.2
|
13
|
+
|
14
|
+
#### Changed
|
15
|
+
|
16
|
+
* More ActiveSupport removal. Better ENV.to_h.
|
17
|
+
|
18
|
+
## v2.2.1
|
19
|
+
|
20
|
+
#### Changed
|
21
|
+
|
22
|
+
* More ActiveSupport removal from SsmParameterStore.
|
23
|
+
|
24
|
+
## v2.2.0
|
25
|
+
|
26
|
+
#### Changed
|
27
|
+
|
28
|
+
* Remove dependency on `activesupport` for rack-only applications.
|
29
|
+
* Remove ActiveSupport artifacts:
|
30
|
+
- Replace `strip_heredoc` with `<<~HEREDOC`.
|
31
|
+
- Remove instances of `Object#try`, replace with `&.`.
|
32
|
+
- Use `Rack::Utils.build_nested_query` in place of `Object#to_query`.
|
33
|
+
- Replace `Object#present?` with `to_s.empty?`.
|
34
|
+
- Replace `Array.wrap` with `Array[obj].compact.flatten`.
|
35
|
+
* Add a check against the `RAILS_ENV` AND `RACK_ENV` environment
|
36
|
+
variables prior to enabling debug mode.
|
37
|
+
|
38
|
+
## v2.1.0
|
39
|
+
|
40
|
+
#### Changed
|
41
|
+
|
42
|
+
* Only load the railtie if `Rails` is defined.
|
43
|
+
|
5
44
|
## v2.0.1
|
6
45
|
|
7
46
|
#### Changed
|
@@ -22,7 +61,7 @@ Support for new API Gateway HTTP APIs!!!
|
|
22
61
|
|
23
62
|
#### Added
|
24
63
|
|
25
|
-
* New
|
64
|
+
* New rack handler for HTTP API v1 and v2.
|
26
65
|
* Lots of backfill tests for, ALBs & REST APIs.
|
27
66
|
|
28
67
|
|
data/Gemfile.lock
CHANGED
data/lib/lamby.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'lamby/logger'
|
2
2
|
require 'rack'
|
3
3
|
require 'base64'
|
4
|
-
require 'active_support/all'
|
5
4
|
require 'lamby/version'
|
6
5
|
require 'lamby/sam_helpers'
|
7
6
|
require 'lamby/rack'
|
@@ -10,8 +9,11 @@ require 'lamby/rack_rest'
|
|
10
9
|
require 'lamby/rack_http'
|
11
10
|
require 'lamby/debug'
|
12
11
|
require 'lamby/handler'
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
if defined?(Rails)
|
14
|
+
require 'rails/railtie'
|
15
|
+
require 'lamby/railtie'
|
16
|
+
end
|
15
17
|
|
16
18
|
module Lamby
|
17
19
|
|
data/lib/lamby/debug.rb
CHANGED
@@ -6,7 +6,7 @@ module Lamby
|
|
6
6
|
|
7
7
|
def on?(event)
|
8
8
|
params = event['multiValueQueryStringParameters'] || event['queryStringParameters']
|
9
|
-
(
|
9
|
+
(development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1'
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(event, context, env)
|
@@ -42,5 +42,12 @@ module Lamby
|
|
42
42
|
HTML
|
43
43
|
end
|
44
44
|
|
45
|
+
def development?
|
46
|
+
ENV.to_h
|
47
|
+
.slice('RACK_ENV', 'RAILS_ENV')
|
48
|
+
.values
|
49
|
+
.any? { |v| v.to_s.casecmp('development').zero? }
|
50
|
+
end
|
51
|
+
|
45
52
|
end
|
46
53
|
end
|
data/lib/lamby/rack.rb
CHANGED
@@ -71,10 +71,20 @@ module Lamby
|
|
71
71
|
value.map{ |v| "#{key}=#{v}" }.join('&')
|
72
72
|
end.flatten.join('&')
|
73
73
|
else
|
74
|
-
|
74
|
+
build_query_string
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def build_query_string
|
79
|
+
return if event['queryStringParameters'].nil?
|
80
|
+
|
81
|
+
Rack::Utils.build_nested_query(
|
82
|
+
event.fetch('queryStringParameters')
|
83
|
+
)
|
84
|
+
.gsub('[', '%5B')
|
85
|
+
.gsub(']', '%5D')
|
86
|
+
end
|
87
|
+
|
78
88
|
def base64_encoded?
|
79
89
|
event['isBase64Encoded']
|
80
90
|
end
|
data/lib/lamby/rack_alb.rb
CHANGED
@@ -11,7 +11,7 @@ module Lamby
|
|
11
11
|
|
12
12
|
def response(handler)
|
13
13
|
hhdrs = handler.headers
|
14
|
-
multivalue_headers = hhdrs.transform_values { |v| Array.
|
14
|
+
multivalue_headers = hhdrs.transform_values { |v| Array[v].compact.flatten } if multi_value?
|
15
15
|
status_description = "#{handler.status} #{::Rack::Utils::HTTP_STATUS_CODES[handler.status]}"
|
16
16
|
base64_encode = hhdrs['Content-Transfer-Encoding'] == 'binary' || hhdrs['X-Lamby-Base64'] == '1'
|
17
17
|
body = Base64.strict_encode64(handler.body) if base64_encode
|
data/lib/lamby/rack_http.rb
CHANGED
@@ -38,8 +38,8 @@ module Lamby
|
|
38
38
|
|
39
39
|
def env_headers
|
40
40
|
super.tap do |hdrs|
|
41
|
-
if
|
42
|
-
hdrs[HTTP_COOKIE] =
|
41
|
+
if cookies.any?
|
42
|
+
hdrs[HTTP_COOKIE] = cookies.join('; ')
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
@@ -48,6 +48,10 @@ module Lamby
|
|
48
48
|
event.dig('requestContext', 'http', 'method') || event['httpMethod']
|
49
49
|
end
|
50
50
|
|
51
|
+
def cookies
|
52
|
+
event['cookies'] || []
|
53
|
+
end
|
54
|
+
|
51
55
|
# Using custom domain names with v1.0 yields a good `path` parameter sans
|
52
56
|
# stage. However, v2.0 and others do not. So we are just going to remove stage
|
53
57
|
# no matter waht from other places for both.
|
@@ -16,12 +16,13 @@ module Lamby
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get!(path)
|
19
|
-
parts = path
|
19
|
+
parts = path[1..-1].split('/')
|
20
20
|
env = parts.pop
|
21
21
|
path = "/#{parts.join('/')}"
|
22
|
-
new(path).get!.params.detect do |p|
|
22
|
+
param = new(path).get!.params.detect do |p|
|
23
23
|
p.env == env
|
24
|
-
end
|
24
|
+
end
|
25
|
+
param&.value
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
@@ -44,7 +45,7 @@ module Lamby
|
|
44
45
|
|
45
46
|
def get!
|
46
47
|
get_all!
|
47
|
-
get_history!
|
48
|
+
get_history! unless label.to_s.empty?
|
48
49
|
self
|
49
50
|
end
|
50
51
|
|
@@ -98,7 +99,7 @@ module Lamby
|
|
98
99
|
with_decryption: true,
|
99
100
|
max_results: MAX_RESULTS
|
100
101
|
}.tap { |options|
|
101
|
-
token = @all_response
|
102
|
+
token = @all_response&.next_token
|
102
103
|
options[:next_token] = token if token
|
103
104
|
}
|
104
105
|
end
|
@@ -137,7 +138,7 @@ module Lamby
|
|
137
138
|
with_decryption: true,
|
138
139
|
max_results: MAX_RESULTS
|
139
140
|
}.tap { |options|
|
140
|
-
token = @hist_response
|
141
|
+
token = @hist_response&.next_token
|
141
142
|
options[:next_token] = token if token
|
142
143
|
}
|
143
144
|
end
|
data/lib/lamby/templates/alb.rb
CHANGED
@@ -7,19 +7,27 @@ say 'Copying files...'
|
|
7
7
|
copy_file tpl_file('app.rb'), app_file('app.rb')
|
8
8
|
copy_file tpl_file('template.yaml'), app_file('template.yaml')
|
9
9
|
gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
10
|
+
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
|
+
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
|
+
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
10
13
|
|
11
14
|
say 'Adding to .gitignore...'
|
12
15
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
16
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
17
|
# Lamby
|
15
18
|
/.aws-sam
|
19
|
+
/.lamby
|
16
20
|
GITIGNORE
|
17
21
|
|
18
22
|
say 'Creating ./bin files for build and deploy...'
|
19
|
-
copy_file tpl_file('
|
20
|
-
|
23
|
+
copy_file tpl_file('_build'), app_file('bin/_build')
|
24
|
+
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
|
+
chmod app_file('bin/_build'), 0755
|
21
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
22
27
|
chmod app_file('bin/deploy'), 0755
|
28
|
+
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
|
+
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
|
+
chmod app_file('bin/_deploy'), 0755
|
23
31
|
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
24
32
|
|
25
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
|
+
|
3
|
+
# Ensure minimum required SAM version.
|
4
|
+
# RUN pip install awscli && \
|
5
|
+
# pip uninstall --yes aws-sam-cli && \
|
6
|
+
# pip install aws-sam-cli==v1.13.2
|
7
|
+
|
8
|
+
# Node for JavaScript.
|
9
|
+
# RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
|
10
|
+
# yum install -y nodejs && \
|
11
|
+
# curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
12
|
+
# rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
13
|
+
# yum install -y yarn
|
14
|
+
|
15
|
+
WORKDIR /var/task
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
echo '== Simulate SAM Build Directory =='
|
5
|
+
RESOURCE="RailsLambda"
|
6
|
+
SAM_TEMP=$(mktemp -d -t sam.XXXXXX)
|
7
|
+
rm -rf ./.lamby ./.aws-sam
|
8
|
+
cp -r . "$SAM_TEMP"
|
9
|
+
mkdir -p ./.lamby
|
10
|
+
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
+
pushd "./.lamby/$RESOURCE"
|
12
|
+
|
13
|
+
echo '== Cleaning Dev Dependencies =='
|
14
|
+
rm -rf ./.bundle \
|
15
|
+
./vendor/bundle
|
16
|
+
|
17
|
+
echo '== Bundle For Deployment =='
|
18
|
+
bundle config --local deployment true
|
19
|
+
bundle config --local without 'development test'
|
20
|
+
bundle config --local path './vendor/bundle'
|
21
|
+
bundle install --quiet --jobs 4
|
22
|
+
|
23
|
+
echo "== Environments & Configuration =="
|
24
|
+
# ./bin/rails \
|
25
|
+
# -rlamby \
|
26
|
+
# lamby:ssm:dotenv \
|
27
|
+
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
|
+
|
29
|
+
echo "== Asset Hosts & Precompiling =="
|
30
|
+
# NODE_ENV='production' \
|
31
|
+
# RAILS_GROUPS=assets \
|
32
|
+
# ./bin/rails assets:precompile
|
33
|
+
|
34
|
+
echo "== Cleanup Unused Files & Directories =="
|
35
|
+
rm -rf \
|
36
|
+
log \
|
37
|
+
node_modules \
|
38
|
+
test \
|
39
|
+
tmp \
|
40
|
+
vendor/bundle/ruby/2.7.0/cache
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
5
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
7
|
+
|
8
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
9
|
+
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
|
+
|
12
|
+
./bin/_build
|
13
|
+
|
14
|
+
export VPCID=${VPCID:=$(
|
15
|
+
aws ec2 describe-vpcs \
|
16
|
+
--output text \
|
17
|
+
--filters 'Name=state,Values=available' \
|
18
|
+
--query 'Vpcs[0].VpcId'
|
19
|
+
)}
|
20
|
+
|
21
|
+
export SUBNETS=${SUBNETS:=$(
|
22
|
+
aws ec2 describe-subnets \
|
23
|
+
--output text \
|
24
|
+
--filters "Name=state,Values=available,Name=vpc-id,Values=$VPCID" \
|
25
|
+
--query 'Subnets[*].SubnetId' | \
|
26
|
+
tr -s '[:blank:]' ','
|
27
|
+
)}
|
28
|
+
|
29
|
+
sam build \
|
30
|
+
--parameter-overrides \
|
31
|
+
RailsEnv="${RAILS_ENV}"
|
32
|
+
|
33
|
+
echo "== SAM package..."
|
34
|
+
sam package \
|
35
|
+
--region "$AWS_DEFAULT_REGION" \
|
36
|
+
--template-file ./.aws-sam/build/template.yaml \
|
37
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
38
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
39
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
40
|
+
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
41
|
+
|
42
|
+
echo "== SAM deploy..."
|
43
|
+
sam deploy \
|
44
|
+
--region "$AWS_DEFAULT_REGION" \
|
45
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
46
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
47
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
48
|
+
--capabilities "CAPABILITY_IAM" \
|
49
|
+
--parameter-overrides \
|
50
|
+
RailsEnv="${RAILS_ENV}" \
|
51
|
+
VpcId=${VPCID} \
|
52
|
+
Subnets=${SUBNETS}
|
@@ -1,39 +1,9 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export RAILS_ENV=${RAILS_ENV:=
|
5
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
4
|
+
export RAILS_ENV=${RAILS_ENV:=production}
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
--output text \
|
13
|
-
--filters 'Name=state,Values=available' \
|
14
|
-
--query 'Vpcs[0].VpcId'
|
15
|
-
)}
|
16
|
-
|
17
|
-
export SUBNETS=${SUBNETS:=$(
|
18
|
-
aws ec2 describe-subnets \
|
19
|
-
--output text \
|
20
|
-
--filters "Name=state,Values=available,Name=vpc-id,Values=$VPCID" \
|
21
|
-
--query 'Subnets[*].SubnetId' | \
|
22
|
-
tr -s '[:blank:]' ','
|
23
|
-
)}
|
24
|
-
|
25
|
-
sam package \
|
26
|
-
--region ${AWS_DEFAULT_REGION} \
|
27
|
-
--template-file ./.aws-sam/build/template.yaml \
|
28
|
-
--output-template-file ./.aws-sam/build/packaged.yaml \
|
29
|
-
--s3-bucket $CLOUDFORMATION_BUCKET \
|
30
|
-
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
31
|
-
|
32
|
-
sam deploy \
|
33
|
-
--template-file ./.aws-sam/build/packaged.yaml \
|
34
|
-
--stack-name "APPNAMEHERE-${RAILS_ENV}-${AWS_DEFAULT_REGION}" \
|
35
|
-
--capabilities "CAPABILITY_IAM" \
|
36
|
-
--parameter-overrides \
|
37
|
-
RailsEnv=${RAILS_ENV} \
|
38
|
-
VpcId=${VPCID} \
|
39
|
-
Subnets=${SUBNETS}
|
6
|
+
docker-compose run \
|
7
|
+
-e CLOUDFORMATION_BUCKET \
|
8
|
+
cicd \
|
9
|
+
./bin/_deploy
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version: '3.7'
|
2
|
+
services:
|
3
|
+
cicd:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile-build
|
7
|
+
environment:
|
8
|
+
- RAILS_ENV=${RAILS_ENV-development}
|
9
|
+
- AWS_PROFILE=${AWS_PROFILE-default}
|
10
|
+
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
+
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
|
12
|
+
volumes:
|
13
|
+
- ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
|
14
|
+
- ~/.aws:/root/.aws:delegated
|
15
|
+
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
+
- .:/var/task:delegated
|
17
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
@@ -28,14 +28,14 @@ Resources:
|
|
28
28
|
|
29
29
|
RailsLoadBalancerTargetGroup:
|
30
30
|
Type: AWS::ElasticLoadBalancingV2::TargetGroup
|
31
|
-
DependsOn:
|
31
|
+
DependsOn: RailsLambdaInvokePermission
|
32
32
|
Properties:
|
33
33
|
TargetType: lambda
|
34
34
|
TargetGroupAttributes:
|
35
35
|
- Key: lambda.multi_value_headers.enabled
|
36
36
|
Value: true
|
37
37
|
Targets:
|
38
|
-
- Id: !GetAtt
|
38
|
+
- Id: !GetAtt RailsLambda.Arn
|
39
39
|
|
40
40
|
RailsLoadBalancerHttpListener:
|
41
41
|
Type: 'AWS::ElasticLoadBalancingV2::Listener'
|
@@ -58,26 +58,26 @@ Resources:
|
|
58
58
|
ToPort: 80
|
59
59
|
CidrIp: 0.0.0.0/0
|
60
60
|
|
61
|
-
|
61
|
+
RailsLambdaInvokePermission:
|
62
62
|
Type: AWS::Lambda::Permission
|
63
63
|
Properties:
|
64
|
-
FunctionName: !GetAtt
|
64
|
+
FunctionName: !GetAtt RailsLambda.Arn
|
65
65
|
Action: 'lambda:InvokeFunction'
|
66
66
|
Principal: elasticloadbalancing.amazonaws.com
|
67
67
|
|
68
|
-
|
68
|
+
RailsLambda:
|
69
69
|
Type: AWS::Serverless::Function
|
70
|
+
Metadata:
|
71
|
+
DockerContext: ./.lamby/RailsLambda
|
72
|
+
Dockerfile: Dockerfile
|
70
73
|
Properties:
|
71
|
-
CodeUri: .
|
72
|
-
Handler: app.handler
|
73
|
-
Runtime: ruby2.7
|
74
74
|
MemorySize: 512
|
75
75
|
Timeout: 30
|
76
76
|
Environment:
|
77
77
|
Variables:
|
78
78
|
RAILS_ENV: !Ref RailsEnv
|
79
79
|
FunctionName: !Join [ '', [ 'APPNAMEHERE-', !Ref RailsEnv, '-', !Ref 'AWS::Region' ] ]
|
80
|
-
|
80
|
+
PackageType: Image
|
81
81
|
|
82
82
|
Outputs:
|
83
83
|
|
@@ -85,6 +85,6 @@ Outputs:
|
|
85
85
|
Description: Application Load Balancer DNS Name
|
86
86
|
Value: !GetAtt RailsLoadBalancer.DNSName
|
87
87
|
|
88
|
-
|
88
|
+
RailsLambdaArn:
|
89
89
|
Description: Lambda ARN
|
90
|
-
Value: !GetAtt
|
90
|
+
Value: !GetAtt RailsLambda.Arn
|
data/lib/lamby/templates/http.rb
CHANGED
@@ -7,19 +7,27 @@ say 'Copying files...'
|
|
7
7
|
copy_file tpl_file('app.rb'), app_file('app.rb')
|
8
8
|
copy_file tpl_file('template.yaml'), app_file('template.yaml')
|
9
9
|
gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
10
|
+
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
|
+
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
|
+
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
10
13
|
|
11
14
|
say 'Adding to .gitignore...'
|
12
15
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
16
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
17
|
# Lamby
|
15
18
|
/.aws-sam
|
19
|
+
/.lamby
|
16
20
|
GITIGNORE
|
17
21
|
|
18
22
|
say 'Creating ./bin files for build and deploy...'
|
19
|
-
copy_file tpl_file('
|
20
|
-
|
23
|
+
copy_file tpl_file('_build'), app_file('bin/_build')
|
24
|
+
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
|
+
chmod app_file('bin/_build'), 0755
|
21
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
22
27
|
chmod app_file('bin/deploy'), 0755
|
28
|
+
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
|
+
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
|
+
chmod app_file('bin/_deploy'), 0755
|
23
31
|
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
24
32
|
|
25
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
|
+
|
3
|
+
# Ensure minimum required SAM version.
|
4
|
+
# RUN pip install awscli && \
|
5
|
+
# pip uninstall --yes aws-sam-cli && \
|
6
|
+
# pip install aws-sam-cli==v1.13.2
|
7
|
+
|
8
|
+
# Node for JavaScript.
|
9
|
+
# RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
|
10
|
+
# yum install -y nodejs && \
|
11
|
+
# curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
12
|
+
# rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
13
|
+
# yum install -y yarn
|
14
|
+
|
15
|
+
WORKDIR /var/task
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
echo '== Simulate SAM Build Directory =='
|
5
|
+
RESOURCE="RailsLambda"
|
6
|
+
SAM_TEMP=$(mktemp -d -t sam.XXXXXX)
|
7
|
+
rm -rf ./.lamby ./.aws-sam
|
8
|
+
cp -r . "$SAM_TEMP"
|
9
|
+
mkdir -p ./.lamby
|
10
|
+
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
+
pushd "./.lamby/$RESOURCE"
|
12
|
+
|
13
|
+
echo '== Cleaning Dev Dependencies =='
|
14
|
+
rm -rf ./.bundle \
|
15
|
+
./vendor/bundle
|
16
|
+
|
17
|
+
echo '== Bundle For Deployment =='
|
18
|
+
bundle config --local deployment true
|
19
|
+
bundle config --local without 'development test'
|
20
|
+
bundle config --local path './vendor/bundle'
|
21
|
+
bundle install --quiet --jobs 4
|
22
|
+
|
23
|
+
echo "== Environments & Configuration =="
|
24
|
+
# ./bin/rails \
|
25
|
+
# -rlamby \
|
26
|
+
# lamby:ssm:dotenv \
|
27
|
+
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
|
+
|
29
|
+
echo "== Asset Hosts & Precompiling =="
|
30
|
+
# NODE_ENV='production' \
|
31
|
+
# RAILS_GROUPS=assets \
|
32
|
+
# ./bin/rails assets:precompile
|
33
|
+
|
34
|
+
echo "== Cleanup Unused Files & Directories =="
|
35
|
+
rm -rf \
|
36
|
+
log \
|
37
|
+
node_modules \
|
38
|
+
test \
|
39
|
+
tmp \
|
40
|
+
vendor/bundle/ruby/2.7.0/cache
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
5
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
7
|
+
|
8
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
9
|
+
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
|
+
|
12
|
+
./bin/_build
|
13
|
+
|
14
|
+
sam build \
|
15
|
+
--parameter-overrides \
|
16
|
+
RailsEnv="${RAILS_ENV}"
|
17
|
+
|
18
|
+
echo "== SAM package..."
|
19
|
+
sam package \
|
20
|
+
--region "$AWS_DEFAULT_REGION" \
|
21
|
+
--template-file ./.aws-sam/build/template.yaml \
|
22
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
23
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
24
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
25
|
+
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
26
|
+
|
27
|
+
echo "== SAM deploy..."
|
28
|
+
sam deploy \
|
29
|
+
--region "$AWS_DEFAULT_REGION" \
|
30
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
31
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
32
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
33
|
+
--capabilities "CAPABILITY_IAM" \
|
34
|
+
--parameter-overrides \
|
35
|
+
RailsEnv="${RAILS_ENV}"
|
@@ -1,22 +1,9 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export RAILS_ENV=${RAILS_ENV:=
|
5
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
4
|
+
export RAILS_ENV=${RAILS_ENV:=production}
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
--template-file ./.aws-sam/build/template.yaml \
|
13
|
-
--output-template-file ./.aws-sam/build/packaged.yaml \
|
14
|
-
--s3-bucket $CLOUDFORMATION_BUCKET \
|
15
|
-
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
16
|
-
|
17
|
-
sam deploy \
|
18
|
-
--template-file ./.aws-sam/build/packaged.yaml \
|
19
|
-
--stack-name "APPNAMEHERE-${RAILS_ENV}-${AWS_DEFAULT_REGION}" \
|
20
|
-
--capabilities "CAPABILITY_IAM" \
|
21
|
-
--parameter-overrides \
|
22
|
-
RailsEnv=${RAILS_ENV}
|
6
|
+
docker-compose run \
|
7
|
+
-e CLOUDFORMATION_BUCKET \
|
8
|
+
cicd \
|
9
|
+
./bin/_deploy
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version: '3.7'
|
2
|
+
services:
|
3
|
+
cicd:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile-build
|
7
|
+
environment:
|
8
|
+
- RAILS_ENV=${RAILS_ENV-development}
|
9
|
+
- AWS_PROFILE=${AWS_PROFILE-default}
|
10
|
+
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
+
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
|
12
|
+
volumes:
|
13
|
+
- ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
|
14
|
+
- ~/.aws:/root/.aws:delegated
|
15
|
+
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
+
- .:/var/task:delegated
|
17
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
@@ -13,12 +13,12 @@ Parameters:
|
|
13
13
|
|
14
14
|
Resources:
|
15
15
|
|
16
|
-
|
16
|
+
RailsLambda:
|
17
17
|
Type: AWS::Serverless::Function
|
18
|
+
Metadata:
|
19
|
+
DockerContext: ./.lamby/RailsLambda
|
20
|
+
Dockerfile: Dockerfile
|
18
21
|
Properties:
|
19
|
-
CodeUri: .
|
20
|
-
Handler: app.handler
|
21
|
-
Runtime: ruby2.7
|
22
22
|
MemorySize: 512
|
23
23
|
Timeout: 30
|
24
24
|
Environment:
|
@@ -30,7 +30,7 @@ Resources:
|
|
30
30
|
Type: HttpApi
|
31
31
|
Properties:
|
32
32
|
ApiId: !Ref RailsApi
|
33
|
-
|
33
|
+
PackageType: Image
|
34
34
|
|
35
35
|
RailsApi:
|
36
36
|
Type: AWS::Serverless::HttpApi
|
@@ -43,6 +43,6 @@ Outputs:
|
|
43
43
|
Description: API Gateway Endpoint
|
44
44
|
Value: !Sub "https://${RailsApi}.execute-api.${AWS::Region}.amazonaws.com/${RailsEnv}/"
|
45
45
|
|
46
|
-
|
46
|
+
RailsLambdaArn:
|
47
47
|
Description: Lambda ARN
|
48
|
-
Value: !GetAtt
|
48
|
+
Value: !GetAtt RailsLambda.Arn
|
data/lib/lamby/templates/rest.rb
CHANGED
@@ -7,19 +7,27 @@ say 'Copying files...'
|
|
7
7
|
copy_file tpl_file('app.rb'), app_file('app.rb')
|
8
8
|
copy_file tpl_file('template.yaml'), app_file('template.yaml')
|
9
9
|
gsub_file app_file('template.yaml'), /APPNAMEHERE/, appname
|
10
|
+
copy_file tpl_file('Dockerfile'), app_file('Dockerfile')
|
11
|
+
copy_file tpl_file('Dockerfile-build'), app_file('Dockerfile-build')
|
12
|
+
copy_file tpl_file('docker-compose.yml'), app_file('docker-compose.yml')
|
10
13
|
|
11
14
|
say 'Adding to .gitignore...'
|
12
15
|
FileUtils.touch app_file('.gitignore')
|
13
|
-
append_to_file app_file('.gitignore'),
|
16
|
+
append_to_file app_file('.gitignore'), <<~GITIGNORE
|
14
17
|
# Lamby
|
15
18
|
/.aws-sam
|
19
|
+
/.lamby
|
16
20
|
GITIGNORE
|
17
21
|
|
18
22
|
say 'Creating ./bin files for build and deploy...'
|
19
|
-
copy_file tpl_file('
|
20
|
-
|
23
|
+
copy_file tpl_file('_build'), app_file('bin/_build')
|
24
|
+
gsub_file app_file('bin/_build'), /APPNAMEHERE/, appname.downcase
|
25
|
+
chmod app_file('bin/_build'), 0755
|
21
26
|
copy_file tpl_file('deploy'), app_file('bin/deploy')
|
22
27
|
chmod app_file('bin/deploy'), 0755
|
28
|
+
copy_file tpl_file('_deploy'), app_file('bin/_deploy')
|
29
|
+
gsub_file app_file('bin/_deploy'), /APPNAMEHERE/, appname.downcase
|
30
|
+
chmod app_file('bin/_deploy'), 0755
|
23
31
|
gsub_file app_file('bin/deploy'), /APPNAMEHERE/, appname.downcase
|
24
32
|
|
25
33
|
say 'Welcome to AWS Lambda and Rails 🎉', :green
|
@@ -0,0 +1,15 @@
|
|
1
|
+
FROM amazon/aws-sam-cli-build-image-ruby2.7
|
2
|
+
|
3
|
+
# Ensure minimum required SAM version.
|
4
|
+
# RUN pip install awscli && \
|
5
|
+
# pip uninstall --yes aws-sam-cli && \
|
6
|
+
# pip install aws-sam-cli==v1.13.2
|
7
|
+
|
8
|
+
# Node for JavaScript.
|
9
|
+
# RUN curl -sL https://rpm.nodesource.com/setup_12.x | bash - && \
|
10
|
+
# yum install -y nodejs && \
|
11
|
+
# curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo && \
|
12
|
+
# rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
|
13
|
+
# yum install -y yarn
|
14
|
+
|
15
|
+
WORKDIR /var/task
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
echo '== Simulate SAM Build Directory =='
|
5
|
+
RESOURCE="RailsLambda"
|
6
|
+
SAM_TEMP=$(mktemp -d -t sam.XXXXXX)
|
7
|
+
rm -rf ./.lamby ./.aws-sam
|
8
|
+
cp -r . "$SAM_TEMP"
|
9
|
+
mkdir -p ./.lamby
|
10
|
+
cp -r "$SAM_TEMP" "./.lamby/$RESOURCE"
|
11
|
+
pushd "./.lamby/$RESOURCE"
|
12
|
+
|
13
|
+
echo '== Cleaning Dev Dependencies =='
|
14
|
+
rm -rf ./.bundle \
|
15
|
+
./vendor/bundle
|
16
|
+
|
17
|
+
echo '== Bundle For Deployment =='
|
18
|
+
bundle config --local deployment true
|
19
|
+
bundle config --local without 'development test'
|
20
|
+
bundle config --local path './vendor/bundle'
|
21
|
+
bundle install --quiet --jobs 4
|
22
|
+
|
23
|
+
echo "== Environments & Configuration =="
|
24
|
+
# ./bin/rails \
|
25
|
+
# -rlamby \
|
26
|
+
# lamby:ssm:dotenv \
|
27
|
+
# LAMBY_SSM_PARAMS_PATH="/APPNAMEHERE/${RAILS_ENV}/env"
|
28
|
+
|
29
|
+
echo "== Asset Hosts & Precompiling =="
|
30
|
+
# NODE_ENV='production' \
|
31
|
+
# RAILS_GROUPS=assets \
|
32
|
+
# ./bin/rails assets:precompile
|
33
|
+
|
34
|
+
echo "== Cleanup Unused Files & Directories =="
|
35
|
+
rm -rf \
|
36
|
+
log \
|
37
|
+
node_modules \
|
38
|
+
test \
|
39
|
+
tmp \
|
40
|
+
vendor/bundle/ruby/2.7.0/cache
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
5
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
7
|
+
|
8
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
9
|
+
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
|
+
|
12
|
+
./bin/_build
|
13
|
+
|
14
|
+
sam build \
|
15
|
+
--parameter-overrides \
|
16
|
+
RailsEnv="${RAILS_ENV}"
|
17
|
+
|
18
|
+
echo "== SAM package..."
|
19
|
+
sam package \
|
20
|
+
--region "$AWS_DEFAULT_REGION" \
|
21
|
+
--template-file ./.aws-sam/build/template.yaml \
|
22
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
23
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
24
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
25
|
+
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
26
|
+
|
27
|
+
echo "== SAM deploy..."
|
28
|
+
sam deploy \
|
29
|
+
--region "$AWS_DEFAULT_REGION" \
|
30
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
31
|
+
--stack-name "APPNAMEHERE-${RAILS_ENV}" \
|
32
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
33
|
+
--capabilities "CAPABILITY_IAM" \
|
34
|
+
--parameter-overrides \
|
35
|
+
RailsEnv="${RAILS_ENV}"
|
@@ -1,22 +1,9 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
set -e
|
3
3
|
|
4
|
-
export RAILS_ENV=${RAILS_ENV:=
|
5
|
-
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
6
|
-
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.$(whoami)"}
|
4
|
+
export RAILS_ENV=${RAILS_ENV:=production}
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
--template-file ./.aws-sam/build/template.yaml \
|
13
|
-
--output-template-file ./.aws-sam/build/packaged.yaml \
|
14
|
-
--s3-bucket $CLOUDFORMATION_BUCKET \
|
15
|
-
--s3-prefix "APPNAMEHERE-${RAILS_ENV}"
|
16
|
-
|
17
|
-
sam deploy \
|
18
|
-
--template-file ./.aws-sam/build/packaged.yaml \
|
19
|
-
--stack-name "APPNAMEHERE-${RAILS_ENV}-${AWS_DEFAULT_REGION}" \
|
20
|
-
--capabilities "CAPABILITY_IAM" \
|
21
|
-
--parameter-overrides \
|
22
|
-
RailsEnv=${RAILS_ENV}
|
6
|
+
docker-compose run \
|
7
|
+
-e CLOUDFORMATION_BUCKET \
|
8
|
+
cicd \
|
9
|
+
./bin/_deploy
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version: '3.7'
|
2
|
+
services:
|
3
|
+
cicd:
|
4
|
+
build:
|
5
|
+
context: .
|
6
|
+
dockerfile: Dockerfile-build
|
7
|
+
environment:
|
8
|
+
- RAILS_ENV=${RAILS_ENV-development}
|
9
|
+
- AWS_PROFILE=${AWS_PROFILE-default}
|
10
|
+
- AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION-us-east-1}
|
11
|
+
- SSH_AUTH_SOCK=${SSH_AUTH_SOCK}
|
12
|
+
volumes:
|
13
|
+
- ${SSH_AUTH_SOCK}:${SSH_AUTH_SOCK}
|
14
|
+
- ~/.aws:/root/.aws:delegated
|
15
|
+
- ~/.ssh/known_hosts:/root/.ssh/known_hosts
|
16
|
+
- .:/var/task:delegated
|
17
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
@@ -28,7 +28,7 @@ Resources:
|
|
28
28
|
x-amazon-apigateway-any-method:
|
29
29
|
x-amazon-apigateway-integration:
|
30
30
|
uri:
|
31
|
-
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${
|
31
|
+
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RailsLambda.Arn}:live/invocations
|
32
32
|
httpMethod: POST
|
33
33
|
type: aws_proxy
|
34
34
|
/{resource+}:
|
@@ -40,18 +40,18 @@ Resources:
|
|
40
40
|
type: string
|
41
41
|
x-amazon-apigateway-integration:
|
42
42
|
uri:
|
43
|
-
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${
|
43
|
+
Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${RailsLambda.Arn}:live/invocations
|
44
44
|
httpMethod: POST
|
45
45
|
type: aws_proxy
|
46
46
|
x-amazon-apigateway-binary-media-types:
|
47
47
|
- '*/*'
|
48
48
|
|
49
|
-
|
49
|
+
RailsLambda:
|
50
50
|
Type: AWS::Serverless::Function
|
51
|
+
Metadata:
|
52
|
+
DockerContext: ./.lamby/RailsLambda
|
53
|
+
Dockerfile: Dockerfile
|
51
54
|
Properties:
|
52
|
-
CodeUri: .
|
53
|
-
Handler: app.handler
|
54
|
-
Runtime: ruby2.7
|
55
55
|
MemorySize: 512
|
56
56
|
Timeout: 30
|
57
57
|
Environment:
|
@@ -71,7 +71,7 @@ Resources:
|
|
71
71
|
Path: /{resource+}
|
72
72
|
Method: ANY
|
73
73
|
RestApiId: !Ref RailsApi
|
74
|
-
|
74
|
+
PackageType: Image
|
75
75
|
|
76
76
|
Outputs:
|
77
77
|
|
@@ -79,6 +79,6 @@ Outputs:
|
|
79
79
|
Description: API Gateway Endpoint
|
80
80
|
Value: !Sub "https://${RailsApi}.execute-api.${AWS::Region}.amazonaws.com/${RailsEnv}/"
|
81
81
|
|
82
|
-
|
82
|
+
RailsLambdaArn:
|
83
83
|
Description: Lambda ARN
|
84
|
-
Value: !GetAtt
|
84
|
+
Value: !GetAtt RailsLambda.Arn
|
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.0
|
4
|
+
version: 2.5.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: 2020-
|
11
|
+
date: 2020-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -163,19 +163,31 @@ files:
|
|
163
163
|
- lib/lamby/tasks.rake
|
164
164
|
- lib/lamby/templates.rake
|
165
165
|
- lib/lamby/templates/alb.rb
|
166
|
+
- lib/lamby/templates/alb/Dockerfile
|
167
|
+
- lib/lamby/templates/alb/Dockerfile-build
|
168
|
+
- lib/lamby/templates/alb/_build
|
169
|
+
- lib/lamby/templates/alb/_deploy
|
166
170
|
- lib/lamby/templates/alb/app.rb
|
167
|
-
- lib/lamby/templates/alb/build
|
168
171
|
- lib/lamby/templates/alb/deploy
|
172
|
+
- lib/lamby/templates/alb/docker-compose.yml
|
169
173
|
- lib/lamby/templates/alb/template.yaml
|
170
174
|
- lib/lamby/templates/http.rb
|
175
|
+
- lib/lamby/templates/http/Dockerfile
|
176
|
+
- lib/lamby/templates/http/Dockerfile-build
|
177
|
+
- lib/lamby/templates/http/_build
|
178
|
+
- lib/lamby/templates/http/_deploy
|
171
179
|
- lib/lamby/templates/http/app.rb
|
172
|
-
- lib/lamby/templates/http/build
|
173
180
|
- lib/lamby/templates/http/deploy
|
181
|
+
- lib/lamby/templates/http/docker-compose.yml
|
174
182
|
- lib/lamby/templates/http/template.yaml
|
175
183
|
- lib/lamby/templates/rest.rb
|
184
|
+
- lib/lamby/templates/rest/Dockerfile
|
185
|
+
- lib/lamby/templates/rest/Dockerfile-build
|
186
|
+
- lib/lamby/templates/rest/_build
|
187
|
+
- lib/lamby/templates/rest/_deploy
|
176
188
|
- lib/lamby/templates/rest/app.rb
|
177
|
-
- lib/lamby/templates/rest/build
|
178
189
|
- lib/lamby/templates/rest/deploy
|
190
|
+
- lib/lamby/templates/rest/docker-compose.yml
|
179
191
|
- lib/lamby/templates/rest/template.yaml
|
180
192
|
- lib/lamby/templates/shared.rb
|
181
193
|
- lib/lamby/version.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -e
|
3
|
-
|
4
|
-
# Clean any previous bundle/builds.
|
5
|
-
rm -rf ./.aws-sam/build
|
6
|
-
|
7
|
-
# Ensure native extensions built for platform.
|
8
|
-
sam build --use-container
|
9
|
-
|
10
|
-
# [HOOK] Environments & Configuration
|
11
|
-
# https://lamby.custominktech.com/docs/environment_and_configuration
|
12
|
-
|
13
|
-
# [HOOK] Asset Hosts & Precompiling
|
14
|
-
# https://lamby.custominktech.com/docs/asset_host_and_precompiling
|
15
|
-
|
16
|
-
# Clean un-needed artifacts.
|
17
|
-
pushd ./.aws-sam/build/RailsFunction/
|
18
|
-
rm -rf .aws-sam \
|
19
|
-
.git \
|
20
|
-
log \
|
21
|
-
test \
|
22
|
-
tmp
|
23
|
-
popd
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -e
|
3
|
-
|
4
|
-
# Clean any previous bundle/builds.
|
5
|
-
rm -rf ./.aws-sam/build
|
6
|
-
|
7
|
-
# Ensure native extensions built for platform.
|
8
|
-
sam build --use-container
|
9
|
-
|
10
|
-
# [HOOK] Environments & Configuration
|
11
|
-
# https://lamby.custominktech.com/docs/environment_and_configuration
|
12
|
-
|
13
|
-
# [HOOK] Asset Hosts & Precompiling
|
14
|
-
# https://lamby.custominktech.com/docs/asset_host_and_precompiling
|
15
|
-
|
16
|
-
# Clean un-needed artifacts.
|
17
|
-
pushd ./.aws-sam/build/RailsFunction/
|
18
|
-
rm -rf .aws-sam \
|
19
|
-
.git \
|
20
|
-
log \
|
21
|
-
test \
|
22
|
-
tmp
|
23
|
-
popd
|
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -e
|
3
|
-
|
4
|
-
# Clean any previous bundle/builds.
|
5
|
-
rm -rf ./.aws-sam/build
|
6
|
-
|
7
|
-
# Ensure native extensions built for platform.
|
8
|
-
sam build --use-container
|
9
|
-
|
10
|
-
# [HOOK] Environments & Configuration
|
11
|
-
# https://lamby.custominktech.com/docs/environment_and_configuration
|
12
|
-
|
13
|
-
# [HOOK] Asset Hosts & Precompiling
|
14
|
-
# https://lamby.custominktech.com/docs/asset_host_and_precompiling
|
15
|
-
|
16
|
-
# Clean un-needed artifacts.
|
17
|
-
pushd ./.aws-sam/build/RailsFunction/
|
18
|
-
rm -rf .aws-sam \
|
19
|
-
.git \
|
20
|
-
log \
|
21
|
-
test \
|
22
|
-
tmp
|
23
|
-
popd
|