Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ You can find your API Gateway Endpoint URL in the output values displayed after
Build your application with the `sam build` command.

```bash
zeroae.gate$ sam build
zeroae.gate$ sam build
```

The SAM CLI installs dependencies defined in `gate-app/build.gradle`, creates a deployment package, and saves it in the `.aws-sam/build` folder.
Expand Down
3 changes: 1 addition & 2 deletions examples/complete/gate-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ task packagegapp() {

task gatecloudUnpack(type: Copy) {
def zipFile = file("application.zip")
def outputDir = gateApplicationDir

from zipTree(zipFile)
into outputDir
into gateApplicationDir
}
sourceSets.main.output.dir gateCloudDir, builtBy: gatecloudUnpack
20 changes: 19 additions & 1 deletion examples/complete/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,33 @@ Globals:
Timeout: 120

Resources:
ZAERuntimeWrapper:
Type: AWS::Serverless::LayerVersion
Metadata:
BuildMethod: makefile
Properties:
Description: ZeroAE's Runtime Wrapper
ContentUri: ../../runtime-wrapper
LicenseInfo: "Apache-2.0"
RetentionPolicy: Delete

LambdaGateApp:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: gate-app
Handler: co.zeroae.gate.App::handleRequest
Runtime: java8.al2
MemorySize: 768
MemorySize: 512
Layers:
- !Ref ZAERuntimeWrapper
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
AWS_LAMBDA_EXEC_WRAPPER: /opt/bin/wrapper.sh
AWS_LAMBDA_EXEC_WRAPPER_EXCLUDE_ARGS: >-
-XX:+UseSerialGC
JAVA_TOOL_OPTIONS: >-
-XX:+PrintGC
-XX:+PrintGCDetails
GATE_APP_NAME: application
GATE_APP_COST_PER_REQUEST: 1
GATE_APP_DAILY_QUOTA: 10000
Expand Down
3 changes: 3 additions & 0 deletions runtime-wrapper/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build-%:
mkdir -p "$(ARTIFACTS_DIR)/bin"
cp wrapper.sh "$(ARTIFACTS_DIR)/bin"
16 changes: 16 additions & 0 deletions runtime-wrapper/wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# the path to the interpreter and all of the originally intended arguments
args=("$@")

# remove any argument that matches AWS_LAMBDA_EXEC_WRAPPER_EXCLUDE_ARGS
for index in "${!args[@]}"; do
if [[ ${args[$index]} == *$AWS_LAMBDA_EXEC_WRAPPER_EXCLUDE_ARGS* ]]; then
unset args[$index]
fi
done

# insert the extra options
# args=("${args[@]:0:$#-1}" "${extra_args[@]}" "${args[@]: -1}")

# start the runtime with the extra options
exec "${args[@]}"
11 changes: 11 additions & 0 deletions template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ Parameters:
Description: The Layer version (SNAPSHOT, 1.0.0, etc...)

Resources:
ZAERuntimeWrapper:
Type: AWS::Serverless::LayerVersion
Metadata:
BuildMethod: makefile
Properties:
LayerName: zae-lambda-runtime-wrapper
Description: ZeroAE's Runtime Wrapper
ContentUri: runtime-wrapper
LicenseInfo: "Apache-2.0"
RetentionPolicy: Retain

ZAEGateLambdaLayer:
Type: AWS::Serverless::LayerVersion
Metadata:
Expand Down