BundlingOptions Struct
Bundling options.
| Source | core/lib/bundling.ts |
|---|---|
| Type last changed |
Example
new lambda.Function(this, 'JavaFunction', {
code: lambda.Code.fromAsset(path.join(__dirname, 'my-java-handler'), {
bundling: {
image: DockerImage.fromRegistry('public.ecr.aws/sam/build-java21:1.153'), // example: the last image with Gradle 8.x
command: ['bash', '-c', 'gradle build && cp build/distributions/*.zip /asset-output/'], // adjust to your build
},
}),
runtime: lambda.Runtime.JAVA_21,
handler: 'com.example.Handler::handleRequest',
});
from aws_cdk import BundlingOptions
lambda_.Function(self, "JavaFunction",
code=lambda_.Code.from_asset(path.join(__dirname, "my-java-handler"),
bundling=BundlingOptions(
image=DockerImage.from_registry("public.ecr.aws/sam/build-java21:1.153"), # example: the last image with Gradle 8.x
command=["bash", "-c", "gradle build && cp build/distributions/*.zip /asset-output/"]
)
),
runtime=lambda_.Runtime.JAVA_21,
handler="com.example.Handler::handleRequest"
)
Function.Builder.create(this, "JavaFunction")
.code(Code.fromAsset(join(__dirname, "my-java-handler"), AssetOptions.builder()
.bundling(BundlingOptions.builder()
.image(DockerImage.fromRegistry("public.ecr.aws/sam/build-java21:1.153")) // example: the last image with Gradle 8.x
.command(List.of("bash", "-c", "gradle build && cp build/distributions/*.zip /asset-output/"))
.build())
.build()))
.runtime(Runtime.JAVA_21)
.handler("com.example.Handler::handleRequest")
.build();
// Install: dotnet add package Amazon.CDK.Lib
new Function(this, "JavaFunction", new FunctionProps {
Code = Code.FromAsset(Join(__dirname, "my-java-handler"), new AssetOptions {
Bundling = new BundlingOptions {
Image = DockerImage.FromRegistry("public.ecr.aws/sam/build-java21:1.153"), // example: the last image with Gradle 8.x
Command = new [] { "bash", "-c", "gradle build && cp build/distributions/*.zip /asset-output/" }
}
}),
Runtime = Runtime.JAVA_21,
Handler = "com.example.Handler::handleRequest"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambda.NewFunction(this, jsii.String("JavaFunction"), &FunctionProps{
Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("my-java-handler")), &AssetOptions{
Bundling: &BundlingOptions{
Image: awscdk.DockerImage_FromRegistry(jsii.String("public.ecr.aws/sam/build-java21:1.153")),
// example: the last image with Gradle 8.x
Command: []*string{
jsii.String("bash"),
jsii.String("-c"),
jsii.String("gradle build && cp build/distributions/*.zip /asset-output/"),
},
},
}),
Runtime: lambda.Runtime_JAVA_21(),
Handler: jsii.String("com.example.Handler::handleRequest"),
})
Properties
bundlingFileAccessoptionalBundlingFileAccessbundling_file_accessoptionalBundlingFileAccessbundlingFileAccessoptionalBundlingFileAccessBundlingFileAccessoptionalBundlingFileAccessBundlingFileAccessoptionalBundlingFileAccess = BundlingFileAccess.BIND_MOUNT #commandoptionalstring[]commandoptionaltyping.List[str]commandoptionalList<String>Commandoptionalstring[]Commandoptional*[]*string #Default: run the command defined in the image
Example value: ['npm', 'install']
entrypointoptionalstring[]entrypointoptionaltyping.List[str]entrypointoptionalList<String>Entrypointoptionalstring[]Entrypointoptional*[]*string #Default: run the entrypoint defined in the image
Example value: ['/bin/sh', '-c']
environmentoptional{ [key: string]: string }environmentoptionaltyping.Mapping[str, str]environmentoptionalMap<String, String>EnvironmentoptionalIDictionary<string, string>Environmentoptional*map[string]*string #Default: no environment variables.
localoptionalILocalBundlinglocaloptionalILocalBundlinglocaloptionalILocalBundlingLocaloptionalILocalBundlingLocaloptionalILocalBundling #Default: bundling will only be performed in a Docker container
The provider implements a method tryBundle() which should return true if local bundling was performed. If false is returned, docker bundling will be done.
networkoptionalstringnetworkoptionalstrnetworkoptionalStringNetworkoptionalstringNetworkoptional*string #Default: no networking options
outputTypeoptionalBundlingOutputoutput_typeoptionalBundlingOutputoutputTypeoptionalBundlingOutputOutputTypeoptionalBundlingOutputOutputTypeoptionalBundlingOutput = BundlingOutput.AUTO_DISCOVER #platformoptionalstringplatformoptionalstrplatformoptionalStringPlatformoptionalstringPlatformoptional*string #Default: no platform specified (the current machine architecture will be used)
Specify this property to build images on a specific platform.
securityOptoptionalstringsecurity_optoptionalstrsecurityOptoptionalStringSecurityOptoptionalstringSecurityOptoptional*string #Default: no security options
Default: uid:gid of the current user or 1000:1000 on Windows
user | user:group | uid | uid:gid | user:gid | uid:group
volumesoptionalDockerVolume[]volumesoptionaltyping.List[DockerVolume]volumesoptionalList<DockerVolume>VolumesoptionalDockerVolume[]Volumesoptional*[]DockerVolume #Default: no additional volumes are mounted
volumesFromoptionalstring[]volumes_fromoptionaltyping.List[str]volumesFromoptionalList<String>VolumesFromoptionalstring[]VolumesFromoptional*[]*string #Default: no containers are specified to mount volumes from
workingDirectoryoptionalstringworking_directoryoptionalstrworkingDirectoryoptionalStringWorkingDirectoryoptionalstringWorkingDirectoryoptional*string = /asset-input #