designs/build_for_provided_runtimes.md
provided runtimes.Serverless Function resources can now have a Metadata Resource Attribute which specifies a BuildMethod.
BuildMethod will either be the official lambda runtime identifiers such as python3.8, nodejs20.x etc or makefile.
If BuildMethod is specified to be makefile, the build targets that are present in the Makefile which take the form of
build-{resource_logical_id} will be executed.
More details can also be found at: CustomMakeBuildWorkflow
This enables following usecases:
provided runtimes.sam build natively offers.provided runtimes through sam build directly.Template
Resources:
HelloRustFunction:
Type: AWS::Serverless::Function
Properties:
Handler: bootstrap.is.real.handler
Runtime: provided
MemorySize: 512
CodeUri: .
Metadata:
BuildMethod: makefile
Makefile
build-HelloRustFunction:
cargo build --release --target x86_64-unknown-linux-musl
cp ./target/x86_64-unknown-linux-musl/release/bootstrap $(ARTIFACTS_DIR)
Template
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.7
Metadata:
BuildMethod: makefile
Makefile
build-HelloWorldFunction:
cp *.py $(ARTIFACTS_DIR)
cp requirements.txt $(ARTIFACTS_DIR)
python -m pip install -r requirements.txt -t $(ARTIFACTS_DIR)
rm -rf $(ARTIFACTS_DIR)/bin
python3.8 for a python3.8 runtime?
aws-lambda-buildersruby2.7 for a python3.8 runtime?
python3.7 for a python3.8 runtime?
BuildMethod at all.No changes in CLI interface.
No breaking changes.
provided runtimesmakefile constructmakefile construct