lamby 2.2.2 → 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 +28 -0
- data/Gemfile.lock +2 -2
- data/lib/lamby/handler.rb +13 -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/ssm_parameter_store.rb +1 -1
- data/lib/lamby/templates/alb.rb +10 -2
- 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 +62 -0
- data/lib/lamby/templates/alb/app.rb +2 -0
- data/lib/lamby/templates/alb/deploy +8 -34
- 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 +10 -2
- 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 +45 -0
- data/lib/lamby/templates/http/app.rb +2 -0
- data/lib/lamby/templates/http/deploy +8 -17
- 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 +10 -2
- 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 +45 -0
- data/lib/lamby/templates/rest/app.rb +2 -0
- data/lib/lamby/templates/rest/deploy +8 -17
- 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: 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
@@ -3,6 +3,34 @@
|
|
3
3
|
|
4
4
|
See this http://keepachangelog.com link for information on how we want this documented formatted.
|
5
5
|
|
6
|
+
## v2.6.0
|
7
|
+
|
8
|
+
#### Fixed
|
9
|
+
|
10
|
+
* Support multiple Set-Cookie headers for all rest types.
|
11
|
+
|
12
|
+
## v2.5.3
|
13
|
+
|
14
|
+
#### Fixed
|
15
|
+
|
16
|
+
* Base64 encode response body if the rack response is gzip or brotli compressed.
|
17
|
+
|
18
|
+
## v2.5.2
|
19
|
+
|
20
|
+
* SSM file always overwrites. Fixes #65.
|
21
|
+
|
22
|
+
## v2.5.1
|
23
|
+
|
24
|
+
#### Fixed
|
25
|
+
|
26
|
+
* Quoting in describe-subnets #62 Thanks @atwoodjw
|
27
|
+
|
28
|
+
## v2.5.0
|
29
|
+
|
30
|
+
#### Changed
|
31
|
+
|
32
|
+
* Install files to favor containers.
|
33
|
+
|
6
34
|
## v2.2.2
|
7
35
|
|
8
36
|
#### 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
|
@@ -47,6 +55,7 @@ module Lamby
|
|
47
55
|
def base64_encodeable?
|
48
56
|
@headers && (
|
49
57
|
@headers['Content-Transfer-Encoding'] == 'binary' ||
|
58
|
+
content_encoding_compressed? ||
|
50
59
|
@headers['X-Lamby-Base64'] == '1'
|
51
60
|
)
|
52
61
|
end
|
@@ -80,5 +89,9 @@ module Lamby
|
|
80
89
|
end
|
81
90
|
end
|
82
91
|
|
92
|
+
def content_encoding_compressed?
|
93
|
+
content_encoding_header = @headers['Content-Encoding'] || ''
|
94
|
+
content_encoding_header.split(', ').any? { |h| ['br', 'gzip'].include?(h) }
|
95
|
+
end
|
83
96
|
end
|
84
97
|
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
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
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,62 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
+
|
9
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
+
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
11
|
+
export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
|
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
|
22
|
+
./bin/_build
|
23
|
+
|
24
|
+
export VPCID=${VPCID:=$(
|
25
|
+
aws ec2 describe-vpcs \
|
26
|
+
--output text \
|
27
|
+
--filters 'Name=state,Values=available' \
|
28
|
+
--query 'Vpcs[0].VpcId'
|
29
|
+
)}
|
30
|
+
|
31
|
+
export SUBNETS=${SUBNETS:=$(
|
32
|
+
aws ec2 describe-subnets \
|
33
|
+
--output text \
|
34
|
+
--filters 'Name=state,Values=available' "Name=vpc-id,Values=$VPCID" \
|
35
|
+
--query 'Subnets[*].SubnetId' | \
|
36
|
+
tr -s '[:blank:]' ','
|
37
|
+
)}
|
38
|
+
|
39
|
+
sam build \
|
40
|
+
--parameter-overrides \
|
41
|
+
RailsEnv="${RAILS_ENV}"
|
42
|
+
|
43
|
+
echo "== SAM package..."
|
44
|
+
sam package \
|
45
|
+
--region "$AWS_DEFAULT_REGION" \
|
46
|
+
--template-file ./.aws-sam/build/template.yaml \
|
47
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
48
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
49
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
50
|
+
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
51
|
+
|
52
|
+
echo "== SAM deploy..."
|
53
|
+
sam deploy \
|
54
|
+
--region "$AWS_DEFAULT_REGION" \
|
55
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
56
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
57
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
58
|
+
--capabilities "CAPABILITY_IAM" \
|
59
|
+
--parameter-overrides \
|
60
|
+
RailsEnv="${RAILS_ENV}" \
|
61
|
+
VpcId=${VPCID} \
|
62
|
+
Subnets=${SUBNETS}
|
@@ -1,39 +1,13 @@
|
|
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
|
-
|
6
|
+
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
+
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
+
fi
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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}
|
10
|
+
docker-compose run \
|
11
|
+
-e CLOUDFORMATION_BUCKET \
|
12
|
+
cicd \
|
13
|
+
./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
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,45 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
+
|
9
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
+
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
11
|
+
export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
|
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
|
22
|
+
./bin/_build
|
23
|
+
|
24
|
+
sam build \
|
25
|
+
--parameter-overrides \
|
26
|
+
RailsEnv="${RAILS_ENV}"
|
27
|
+
|
28
|
+
echo "== SAM package..."
|
29
|
+
sam package \
|
30
|
+
--region "$AWS_DEFAULT_REGION" \
|
31
|
+
--template-file ./.aws-sam/build/template.yaml \
|
32
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
33
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
34
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
35
|
+
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
36
|
+
|
37
|
+
echo "== SAM deploy..."
|
38
|
+
sam deploy \
|
39
|
+
--region "$AWS_DEFAULT_REGION" \
|
40
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
41
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
42
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
43
|
+
--capabilities "CAPABILITY_IAM" \
|
44
|
+
--parameter-overrides \
|
45
|
+
RailsEnv="${RAILS_ENV}"
|
@@ -1,22 +1,13 @@
|
|
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
|
-
|
6
|
+
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
+
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
+
fi
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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}
|
10
|
+
docker-compose run \
|
11
|
+
-e CLOUDFORMATION_BUCKET \
|
12
|
+
cicd \
|
13
|
+
./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
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,45 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -e
|
3
|
+
|
4
|
+
export DEPLOYMENT_NAME="myorg/APPNAMEHERE"
|
5
|
+
export RAILS_ENV=${RAILS_ENV:="production"}
|
6
|
+
export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:=us-east-1}
|
7
|
+
export CLOUDFORMATION_BUCKET=${CLOUDFORMATION_BUCKET:="lamby.cloudformation.${DEPLOYMENT_NAME/\//-}"}
|
8
|
+
|
9
|
+
# https://github.com/aws/aws-sam-cli/issues/2447
|
10
|
+
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
|
11
|
+
export IMAGE_REPOSITORY="${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${DEPLOYMENT_NAME}"
|
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
|
22
|
+
./bin/_build
|
23
|
+
|
24
|
+
sam build \
|
25
|
+
--parameter-overrides \
|
26
|
+
RailsEnv="${RAILS_ENV}"
|
27
|
+
|
28
|
+
echo "== SAM package..."
|
29
|
+
sam package \
|
30
|
+
--region "$AWS_DEFAULT_REGION" \
|
31
|
+
--template-file ./.aws-sam/build/template.yaml \
|
32
|
+
--output-template-file ./.aws-sam/build/packaged.yaml \
|
33
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
34
|
+
--s3-bucket "${CLOUDFORMATION_BUCKET}" \
|
35
|
+
--s3-prefix "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}"
|
36
|
+
|
37
|
+
echo "== SAM deploy..."
|
38
|
+
sam deploy \
|
39
|
+
--region "$AWS_DEFAULT_REGION" \
|
40
|
+
--template-file ./.aws-sam/build/packaged.yaml \
|
41
|
+
--stack-name "${DEPLOYMENT_NAME/\//-}-${RAILS_ENV}" \
|
42
|
+
--image-repository "$IMAGE_REPOSITORY" \
|
43
|
+
--capabilities "CAPABILITY_IAM" \
|
44
|
+
--parameter-overrides \
|
45
|
+
RailsEnv="${RAILS_ENV}"
|
@@ -1,22 +1,13 @@
|
|
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
|
-
|
6
|
+
if [[ "$OSTYPE" == *"darwin"* ]]; then
|
7
|
+
export SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
|
8
|
+
fi
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
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}
|
10
|
+
docker-compose run \
|
11
|
+
-e CLOUDFORMATION_BUCKET \
|
12
|
+
cicd \
|
13
|
+
./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.
|
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:
|
11
|
+
date: 2021-03-04 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
|