
- Construct the Docker picture (e.g., native-compile-image).
- Run the container within the background.
- Copy the ultimate zip archive from the container to the construct agent’s native filesystem.
Bash
# Run the container in indifferent mode, giving it a reputation for reference
docker run -d --rm --name native-compile-container native-compile-image
# Copy the compiled zip file from the working container to the construct agent's workspace
docker cp native-compile-container:/workspace/goal/spring-serverless-function.zip./goal/This course of leaves you with a single, deployable spring-serverless-function.zip file, which may then be uploaded to an artifact repository.
Deploying with the AWS CDK
With the deployment artifact prepared, I can outline the Lambda perform utilizing an infrastructure-as-code device just like the AWS Cloud Improvement Equipment (CDK). The CDK code factors to the zip file created by the pipeline and configures the Lambda perform.
TypeScript
// Instance CDK code for outlining the Lambda perform
import * as path from 'path';
import * as lambda from 'aws-cdk-lib/aws-lambda';
// Assuming 'this' is a CDK Stack context
const functionAssetDirectory = '/runtime/goal/spring-serverless-function.zip';
const runtimeDir = path.be part of(__dirname, '..', functionAssetDirectory);
new lambda.Operate(this, 'MyNativeLambda', {
runtime: lambda.Runtime.PROVIDED_AL2023,
code: lambda.Code.fromAsset(runtimeDir),
handler: 'org.springframework.cloud.perform.adapter.aws.FunctionInvoker::handleRequest',
memorySize: 256,
timeout: Period.seconds(30),
//... different configurations
});Right here, lambda.Runtime.PROVIDED_AL2023 specifies that we’re utilizing a customized runtime. The code property factors to our zip archive. Crucially, the handler remains to be set to Spring’s generic FunctionInvoker.
