Show / Hide Table of Contents

Class Code

Represents the Lambda Handler Code.

Inheritance
System.Object
Code
AssetCode
AssetImageCode
CfnParametersCode
EcrImageCode
InlineCode
S3Code
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.AWS.Lambda.dll
Syntax (csharp)
public abstract class Code : DeputyBase
Syntax (vb)
Public MustInherit Class Code
    Inherits DeputyBase
Remarks

ExampleMetadata: infused

Examples
using Amazon.CDK.AWS.Signer;


var signingProfile = new SigningProfile(this, "SigningProfile", new SigningProfileProps {
    Platform = Platform.AWS_LAMBDA_SHA384_ECDSA
});

var codeSigningConfig = new CodeSigningConfig(this, "CodeSigningConfig", new CodeSigningConfigProps {
    SigningProfiles = new [] { signingProfile }
});

new Function(this, "Function", new FunctionProps {
    CodeSigningConfig = codeSigningConfig,
    Runtime = Runtime.NODEJS_16_X,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "lambda-handler"))
});

Synopsis

Constructors

Code()
Code(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Code(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Properties

IsInline

(deprecated) Determines whether this Code is inline code or not.

Methods

Asset(String)

(deprecated) DEPRECATED.

Bind(Construct)

Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.

BindToResource(CfnResource, IResourceBindOptions)

Called after the CFN function resource has been created to allow the code class to bind to it.

Bucket(IBucket, String, String)

(deprecated) DEPRECATED.

CfnParameters(ICfnParametersCodeProps)

(deprecated) DEPRECATED.

FromAsset(String, IAssetOptions)

Loads the function code from a local disk path.

FromAssetImage(String, IAssetImageCodeProps)

Create an ECR image from the specified asset and bind it as the Lambda code.

FromBucket(IBucket, String, String)

Lambda handler code as an S3 object.

FromCfnParameters(ICfnParametersCodeProps)

Creates a new Lambda source defined using CloudFormation parameters.

FromDockerBuild(String, IDockerBuildAssetOptions)

Loads the function code from an asset created by a Docker build.

FromEcrImage(IRepository, IEcrImageCodeProps)

Use an existing ECR image as the Lambda code.

FromInline(String)

Inline code for Lambda handler.

Inline(String)

(deprecated) DEPRECATED.

Constructors

Code()

protected Code()

Code(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Code(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Code(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Code(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Properties

IsInline

(deprecated) Determines whether this Code is inline code or not.

public abstract bool IsInline { get; }
Property Value

System.Boolean

Remarks

Stability: Deprecated

Methods

Asset(String)

(deprecated) DEPRECATED.

public static AssetCode Asset(string path)
Parameters
path System.String
Returns

AssetCode

Remarks

Stability: Deprecated

Bind(Construct)

Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.

public abstract ICodeConfig Bind(Construct scope)
Parameters
scope Construct

The binding scope.

Returns

ICodeConfig

BindToResource(CfnResource, IResourceBindOptions)

Called after the CFN function resource has been created to allow the code class to bind to it.

public virtual void BindToResource(CfnResource resource, IResourceBindOptions options = null)
Parameters
resource CfnResource
options IResourceBindOptions
Remarks

Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.

Bucket(IBucket, String, String)

(deprecated) DEPRECATED.

public static S3Code Bucket(IBucket bucket, string key, string objectVersion = null)
Parameters
bucket IBucket
key System.String
objectVersion System.String
Returns

S3Code

Remarks

Stability: Deprecated

CfnParameters(ICfnParametersCodeProps)

(deprecated) DEPRECATED.

public static CfnParametersCode CfnParameters(ICfnParametersCodeProps props = null)
Parameters
props ICfnParametersCodeProps
Returns

CfnParametersCode

Remarks

Stability: Deprecated

FromAsset(String, IAssetOptions)

Loads the function code from a local disk path.

public static AssetCode FromAsset(string path, IAssetOptions options = null)
Parameters
path System.String

Either a directory with the Lambda code bundle or a .zip file.

options IAssetOptions

Either a directory with the Lambda code bundle or a .zip file.

Returns

AssetCode

FromAssetImage(String, IAssetImageCodeProps)

Create an ECR image from the specified asset and bind it as the Lambda code.

public static AssetImageCode FromAssetImage(string directory, IAssetImageCodeProps props = null)
Parameters
directory System.String

the directory from which the asset must be created.

props IAssetImageCodeProps

properties to further configure the selected image.

Returns

AssetImageCode

FromBucket(IBucket, String, String)

Lambda handler code as an S3 object.

public static S3Code FromBucket(IBucket bucket, string key, string objectVersion = null)
Parameters
bucket IBucket

The S3 bucket.

key System.String

The object key.

objectVersion System.String

Optional S3 object version.

Returns

S3Code

FromCfnParameters(ICfnParametersCodeProps)

Creates a new Lambda source defined using CloudFormation parameters.

public static CfnParametersCode FromCfnParameters(ICfnParametersCodeProps props = null)
Parameters
props ICfnParametersCodeProps

optional construction properties of {@link CfnParametersCode}.

Returns

CfnParametersCode

a new instance of CfnParametersCode

FromDockerBuild(String, IDockerBuildAssetOptions)

Loads the function code from an asset created by a Docker build.

public static AssetCode FromDockerBuild(string path, IDockerBuildAssetOptions options = null)
Parameters
path System.String

The path to the directory containing the Docker file.

options IDockerBuildAssetOptions

Docker build options.

Returns

AssetCode

Remarks

By default, the asset is expected to be located at /asset in the image.

FromEcrImage(IRepository, IEcrImageCodeProps)

Use an existing ECR image as the Lambda code.

public static EcrImageCode FromEcrImage(IRepository repository, IEcrImageCodeProps props = null)
Parameters
repository IRepository

the ECR repository that the image is in.

props IEcrImageCodeProps

properties to further configure the selected image.

Returns

EcrImageCode

FromInline(String)

Inline code for Lambda handler.

public static InlineCode FromInline(string code)
Parameters
code System.String

The actual handler code (limited to 4KiB).

Returns

InlineCode

LambdaInlineCode with inline code.

Inline(String)

(deprecated) DEPRECATED.

public static InlineCode Inline(string code)
Parameters
code System.String
Returns

InlineCode

Remarks

Stability: Deprecated

Back to top Generated by DocFX