@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:40.428Z") @Stability(value=Stable) public abstract class Code extends software.amazon.jsii.JsiiObject
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();
| Modifier | Constructor and Description |
|---|---|
protected |
Code() |
protected |
Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Code(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
abstract CodeConfig |
bind(software.constructs.Construct scope)
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
|
void |
bindToResource(CfnResource _resource)
Called after the CFN function resource has been created to allow the code class to bind to it.
|
void |
bindToResource(CfnResource _resource,
ResourceBindOptions _options)
Called after the CFN function resource has been created to allow the code class to bind to it.
|
static AssetCode |
fromAsset(String path)
Loads the function code from a local disk path.
|
static AssetCode |
fromAsset(String path,
AssetOptions options)
Loads the function code from a local disk path.
|
static AssetImageCode |
fromAssetImage(String directory)
Create an ECR image from the specified asset and bind it as the Lambda code.
|
static AssetImageCode |
fromAssetImage(String directory,
AssetImageCodeProps props)
Create an ECR image from the specified asset and bind it as the Lambda code.
|
static S3Code |
fromBucket(IBucket bucket,
String key)
Lambda handler code as an S3 object.
|
static S3Code |
fromBucket(IBucket bucket,
String key,
String objectVersion)
Lambda handler code as an S3 object.
|
static CfnParametersCode |
fromCfnParameters()
Creates a new Lambda source defined using CloudFormation parameters.
|
static CfnParametersCode |
fromCfnParameters(CfnParametersCodeProps props)
Creates a new Lambda source defined using CloudFormation parameters.
|
static AssetCode |
fromDockerBuild(String path)
Loads the function code from an asset created by a Docker build.
|
static AssetCode |
fromDockerBuild(String path,
DockerBuildAssetOptions options)
Loads the function code from an asset created by a Docker build.
|
static EcrImageCode |
fromEcrImage(IRepository repository)
Use an existing ECR image as the Lambda code.
|
static EcrImageCode |
fromEcrImage(IRepository repository,
EcrImageCodeProps props)
Use an existing ECR image as the Lambda code.
|
static InlineCode |
fromInline(String code)
Inline code for Lambda handler.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Code(software.amazon.jsii.JsiiObjectRef objRef)
protected Code(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) protected Code()
@Stability(value=Stable) @NotNull public static AssetCode fromAsset(@NotNull String path, @Nullable AssetOptions options)
path - Either a directory with the Lambda code bundle or a .zip file. This parameter is required.options - @Stability(value=Stable) @NotNull public static AssetCode fromAsset(@NotNull String path)
path - Either a directory with the Lambda code bundle or a .zip file. This parameter is required.@Stability(value=Stable) @NotNull public static AssetImageCode fromAssetImage(@NotNull String directory, @Nullable AssetImageCodeProps props)
directory - the directory from which the asset must be created. This parameter is required.props - properties to further configure the selected image.@Stability(value=Stable) @NotNull public static AssetImageCode fromAssetImage(@NotNull String directory)
directory - the directory from which the asset must be created. This parameter is required.@Stability(value=Stable) @NotNull public static S3Code fromBucket(@NotNull IBucket bucket, @NotNull String key, @Nullable String objectVersion)
bucket - The S3 bucket. This parameter is required.key - The object key. This parameter is required.objectVersion - Optional S3 object version.@Stability(value=Stable) @NotNull public static S3Code fromBucket(@NotNull IBucket bucket, @NotNull String key)
bucket - The S3 bucket. This parameter is required.key - The object key. This parameter is required.@Stability(value=Stable) @NotNull public static CfnParametersCode fromCfnParameters(@Nullable CfnParametersCodeProps props)
props - optional construction properties of CfnParametersCode.@Stability(value=Stable) @NotNull public static CfnParametersCode fromCfnParameters()
@Stability(value=Stable) @NotNull public static AssetCode fromDockerBuild(@NotNull String path, @Nullable DockerBuildAssetOptions options)
By default, the asset is expected to be located at /asset in the
image.
path - The path to the directory containing the Docker file. This parameter is required.options - Docker build options.@Stability(value=Stable) @NotNull public static AssetCode fromDockerBuild(@NotNull String path)
By default, the asset is expected to be located at /asset in the
image.
path - The path to the directory containing the Docker file. This parameter is required.@Stability(value=Stable) @NotNull public static EcrImageCode fromEcrImage(@NotNull IRepository repository, @Nullable EcrImageCodeProps props)
repository - the ECR repository that the image is in. This parameter is required.props - properties to further configure the selected image.@Stability(value=Stable) @NotNull public static EcrImageCode fromEcrImage(@NotNull IRepository repository)
repository - the ECR repository that the image is in. This parameter is required.@Stability(value=Stable) @NotNull public static InlineCode fromInline(@NotNull String code)
code - The actual handler code (limited to 4KiB). This parameter is required.@Stability(value=Stable) @NotNull public abstract CodeConfig bind(@NotNull software.constructs.Construct scope)
scope - The binding scope. This parameter is required.@Stability(value=Stable)
public void bindToResource(@NotNull
CfnResource _resource,
@Nullable
ResourceBindOptions _options)
Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
_resource - This parameter is required._options - @Stability(value=Stable)
public void bindToResource(@NotNull
CfnResource _resource)
Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.
_resource - This parameter is required.Copyright © 2022. All rights reserved.