Class Code
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.lambda.Code
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
AssetCode,AssetImageCode,CfnParametersCode,EcrImageCode,InlineCode,S3Code
@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)",
date="2023-06-19T16:30:40.687Z")
@Stability(Stable)
public abstract class Code
extends software.amazon.jsii.JsiiObject
Represents the Lambda Handler Code.
Example:
import software.amazon.awscdk.services.signer.*;
SigningProfile signingProfile = SigningProfile.Builder.create(this, "SigningProfile")
.platform(Platform.AWS_LAMBDA_SHA384_ECDSA)
.build();
CodeSigningConfig codeSigningConfig = CodeSigningConfig.Builder.create(this, "CodeSigningConfig")
.signingProfiles(List.of(signingProfile))
.build();
Function.Builder.create(this, "Function")
.codeSigningConfig(codeSigningConfig)
.runtime(Runtime.NODEJS_16_X)
.handler("index.handler")
.code(Code.fromAsset(join(__dirname, "lambda-handler")))
.build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AssetCodeDeprecated.abstract CodeConfigCalled when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.voidbindToResource(CfnResource _resource) Called after the CFN function resource has been created to allow the code class to bind to it.voidbindToResource(CfnResource _resource, ResourceBindOptions _options) Called after the CFN function resource has been created to allow the code class to bind to it.static S3CodeDeprecated.usefromBucketstatic S3CodeDeprecated.usefromBucketstatic CfnParametersCodeDeprecated.usefromCfnParametersstatic CfnParametersCodeDeprecated.usefromCfnParametersstatic AssetCodeLoads the function code from a local disk path.static AssetCodefromAsset(String path, AssetOptions options) Loads the function code from a local disk path.static AssetImageCodefromAssetImage(String directory) Create an ECR image from the specified asset and bind it as the Lambda code.static AssetImageCodefromAssetImage(String directory, AssetImageCodeProps props) Create an ECR image from the specified asset and bind it as the Lambda code.static S3CodefromBucket(IBucket bucket, String key) Lambda handler code as an S3 object.static S3CodefromBucket(IBucket bucket, String key, String objectVersion) Lambda handler code as an S3 object.static CfnParametersCodeCreates a new Lambda source defined using CloudFormation parameters.static CfnParametersCodeCreates a new Lambda source defined using CloudFormation parameters.static AssetCodefromDockerBuild(String path) Loads the function code from an asset created by a Docker build.static AssetCodefromDockerBuild(String path, DockerBuildAssetOptions options) Loads the function code from an asset created by a Docker build.static EcrImageCodefromEcrImage(IRepository repository) Use an existing ECR image as the Lambda code.static EcrImageCodefromEcrImage(IRepository repository, EcrImageCodeProps props) Use an existing ECR image as the Lambda code.static InlineCodefromInline(String code) Inline code for Lambda handler.abstract BooleanDeprecated.this value is ignored since inline is now determined based on the theinlineCodefield ofCodeConfigreturned frombind().static InlineCodeDeprecated.usefromInlineMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Code
protected Code(software.amazon.jsii.JsiiObjectRef objRef) -
Code
protected Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Code
@Stability(Stable) protected Code()
-
-
Method Details
-
asset
Deprecated.usefromAsset(deprecated) DEPRECATED.- Parameters:
path- This parameter is required.
-
bucket
@Stability(Deprecated) @Deprecated @NotNull public static S3Code bucket(@NotNull IBucket bucket, @NotNull String key, @Nullable String objectVersion) Deprecated.usefromBucket(deprecated) DEPRECATED.- Parameters:
bucket- This parameter is required.key- This parameter is required.objectVersion-
-
bucket
@Stability(Deprecated) @Deprecated @NotNull public static S3Code bucket(@NotNull IBucket bucket, @NotNull String key) Deprecated.usefromBucket(deprecated) DEPRECATED.- Parameters:
bucket- This parameter is required.key- This parameter is required.
-
cfnParameters
@Stability(Deprecated) @Deprecated @NotNull public static CfnParametersCode cfnParameters(@Nullable CfnParametersCodeProps props) Deprecated.usefromCfnParameters(deprecated) DEPRECATED.- Parameters:
props-
-
cfnParameters
Deprecated.usefromCfnParameters(deprecated) DEPRECATED. -
fromAsset
@Stability(Stable) @NotNull public static AssetCode fromAsset(@NotNull String path, @Nullable AssetOptions options) Loads the function code from a local disk path.- Parameters:
path- Either a directory with the Lambda code bundle or a .zip file. This parameter is required.options-
-
fromAsset
Loads the function code from a local disk path.- Parameters:
path- Either a directory with the Lambda code bundle or a .zip file. This parameter is required.
-
fromAssetImage
@Stability(Stable) @NotNull public static AssetImageCode fromAssetImage(@NotNull String directory, @Nullable AssetImageCodeProps props) Create an ECR image from the specified asset and bind it as the Lambda code.- Parameters:
directory- the directory from which the asset must be created. This parameter is required.props- properties to further configure the selected image.
-
fromAssetImage
Create an ECR image from the specified asset and bind it as the Lambda code.- Parameters:
directory- the directory from which the asset must be created. This parameter is required.
-
fromBucket
@Stability(Stable) @NotNull public static S3Code fromBucket(@NotNull IBucket bucket, @NotNull String key, @Nullable String objectVersion) Lambda handler code as an S3 object.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.objectVersion- Optional S3 object version.
-
fromBucket
@Stability(Stable) @NotNull public static S3Code fromBucket(@NotNull IBucket bucket, @NotNull String key) Lambda handler code as an S3 object.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.
-
fromCfnParameters
@Stability(Stable) @NotNull public static CfnParametersCode fromCfnParameters(@Nullable CfnParametersCodeProps props) Creates a new Lambda source defined using CloudFormation parameters.- Parameters:
props- optional construction properties ofCfnParametersCode.- Returns:
- a new instance of
CfnParametersCode
-
fromCfnParameters
Creates a new Lambda source defined using CloudFormation parameters.- Returns:
- a new instance of
CfnParametersCode
-
fromDockerBuild
@Stability(Stable) @NotNull public static AssetCode fromDockerBuild(@NotNull String path, @Nullable DockerBuildAssetOptions options) Loads the function code from an asset created by a Docker build.By default, the asset is expected to be located at
/assetin the image.- Parameters:
path- The path to the directory containing the Docker file. This parameter is required.options- Docker build options.
-
fromDockerBuild
Loads the function code from an asset created by a Docker build.By default, the asset is expected to be located at
/assetin the image.- Parameters:
path- The path to the directory containing the Docker file. This parameter is required.
-
fromEcrImage
@Stability(Stable) @NotNull public static EcrImageCode fromEcrImage(@NotNull IRepository repository, @Nullable EcrImageCodeProps props) Use an existing ECR image as the Lambda code.- Parameters:
repository- the ECR repository that the image is in. This parameter is required.props- properties to further configure the selected image.
-
fromEcrImage
@Stability(Stable) @NotNull public static EcrImageCode fromEcrImage(@NotNull IRepository repository) Use an existing ECR image as the Lambda code.- Parameters:
repository- the ECR repository that the image is in. This parameter is required.
-
fromInline
Inline code for Lambda handler.- Parameters:
code- The actual handler code (limited to 4KiB). This parameter is required.- Returns:
LambdaInlineCodewith inline code.
-
inline
Deprecated.usefromInline(deprecated) DEPRECATED.- Parameters:
code- This parameter is required.
-
bind
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.- Parameters:
scope- The binding scope. This parameter is required.
-
bindToResource
@Stability(Stable) public void bindToResource(@NotNull CfnResource _resource, @Nullable ResourceBindOptions _options) Called after the CFN function resource has been created to allow the code class to bind to it.Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
- Parameters:
_resource- This parameter is required._options-
-
bindToResource
Called after the CFN function resource has been created to allow the code class to bind to it.Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
- Parameters:
_resource- This parameter is required.
-
getIsInline
Deprecated.this value is ignored since inline is now determined based on the theinlineCodefield ofCodeConfigreturned frombind().(deprecated) Determines whether this Code is inline code or not.
-
fromAsset