Skip to content

Commit

Permalink
feat: add support for provided.al2023 (#1788)
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianMazur committed May 19, 2024
1 parent 946876c commit 823e770
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/config/supportedRuntimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const supportedRuntimesArchitecture = {
provided: [X86_64],
dotnet6: [ARM64, X86_64],
"provided.al2": [ARM64, X86_64],
"provided.al2023": [ARM64, X86_64],
}

// GO
Expand All @@ -48,7 +49,11 @@ export const supportedNodejs = new Set([
])

// PROVIDED
export const supportedProvided = new Set(["provided", "provided.al2"])
export const supportedProvided = new Set([
"provided",
"provided.al2",
"provided.al2023",
])

// PYTHON
export const supportedPython = new Set([
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/docker/provided-al2023/bootstrap
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 tests/integration/docker/provided-al2023/dockerProvided.test.js
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)
})
})
})
5 changes: 5 additions & 0 deletions tests/integration/docker/provided-al2023/handler.sh
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
}
30 changes: 30 additions & 0 deletions tests/integration/docker/provided-al2023/serverless.yml
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

0 comments on commit 823e770

Please sign in to comment.