-
-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for provided.al2023 (#1788)
- Loading branch information
1 parent
946876c
commit 823e770
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/sh | ||
|
||
set -euo pipefail | ||
|
||
# Initialization - load function handler | ||
source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh" | ||
|
||
# Processing | ||
while true | ||
do | ||
HEADERS="$(mktemp)" | ||
# Get an event | ||
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/next") | ||
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) | ||
|
||
# Execute the handler function from the script | ||
RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA") | ||
|
||
# Send the response | ||
curl -s -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE" -o /dev/null | ||
done |
39 changes: 39 additions & 0 deletions
39
tests/integration/docker/provided-al2023/dockerProvided.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import assert from "node:assert" | ||
import { env } from "node:process" | ||
import { join } from "desm" | ||
import { setup, teardown } from "../../../_testHelpers/index.js" | ||
import { BASE_URL } from "../../../config.js" | ||
|
||
describe("Provided.al2023 with Docker tests", function desc() { | ||
beforeEach(() => | ||
setup({ | ||
servicePath: join(import.meta.url), | ||
}), | ||
) | ||
|
||
afterEach(() => teardown()) | ||
|
||
// | ||
;[ | ||
{ | ||
description: "should work with provided.al2023 in docker container", | ||
expected: { | ||
message: "Hello Provided.al2023!", | ||
}, | ||
path: "/dev/hello", | ||
}, | ||
].forEach(({ description, expected, path }) => { | ||
it(description, async function it() { | ||
// "Could not find 'Docker', skipping tests." | ||
if (!env.DOCKER_DETECTED) { | ||
this.skip() | ||
} | ||
|
||
const url = new URL(path, BASE_URL) | ||
const response = await fetch(url) | ||
const json = await response.json() | ||
|
||
assert.deepEqual(json, expected) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function hello () { | ||
RESPONSE="{\"body\": \"{\\\"message\\\": \\\"Hello Provided.al2023!\\\"}\", \"statusCode\": 200}" | ||
|
||
echo $RESPONSE | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
service: docker-provided-tests | ||
|
||
configValidationMode: error | ||
deprecationNotificationMode: error | ||
|
||
plugins: | ||
- ../../../../src/index.js | ||
|
||
provider: | ||
architecture: x86_64 | ||
deploymentMethod: direct | ||
memorySize: 1024 | ||
name: aws | ||
region: us-east-1 | ||
runtime: provided.al2023 | ||
stage: dev | ||
versionFunctions: false | ||
|
||
custom: | ||
serverless-offline: | ||
noTimeout: true | ||
useDocker: true | ||
|
||
functions: | ||
hello: | ||
events: | ||
- http: | ||
method: get | ||
path: hello | ||
handler: handler.hello |