-
Notifications
You must be signed in to change notification settings - Fork 102
Description
Hey folks π we're looking to add support for "custom" runtimes with defineFunction
! This is a follow-up to the following issues, and serves as a request for feedback on how we're thinking of addressing the feature requests
- Detailed docs for: Go, Python Runtimes functions, how can we create and assign these functionsΒ #1486
- support Python for Function runtimeΒ #949
We are looking to bridge the gap between defineFunction
and defining functions using CDK, which then require sideloading to Amplify resources with CDK (e.g. adding a Python function as a trigger for Storage's underlying S3 bucket). To achieve this, we're thinking about an escape hatch to wrap initialized CDK constructs with defineFunction
:
import { defineFunctionWithAnyLanguage as defineFunction } from "@aws-amplify/backend"
import { Runtime } from "aws-cdk-lib/aws-lambda"
import { GoFunction } from "@aws-cdk/aws-lambda-go-alpha"
import { PythonFunction } from "@aws-cdk/aws-lambda-python-alpha"
// a regular function
defineFunction({
name: "my-regular-function",
})
// a go function
defineFunction((scope) => {
return new GoFunction(scope, "GoFunction", {
entry: "app/cmd/api",
})
})
// a python function
defineFunction((scope) => {
return new PythonFunction(scope, "PythonFunction", {
entry: '/path/to/my/function',
runtime: Runtime.PYTHON_3_8,
})
})
Many of the features of defineFunction
today are specific to the TypeScript developer experience such as secrets, automatic secret resolution, typed environment variables, and sensible default configuration for bundling. Using this escape hatch would opt out of consuming these features.
However, this gives you a way to use Python, Go, or other runtimes with your Functions, and attach to other Amplify resources without CDK. This enables use cases such as:
- Python resolvers for Data models, custom queries
- Go resolvers for Data models, custom queries
- Python-based triggers for Storage
Let us know what you think!