CodeConfig Struct
Result of binding Code into a Function.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_lambda as lambda } from 'aws-cdk-lib';
const codeConfig: lambda.CodeConfig = {
image: {
imageUri: 'imageUri',
// the properties below are optional
cmd: ['cmd'],
entrypoint: ['entrypoint'],
workingDirectory: 'workingDirectory',
},
inlineCode: 'inlineCode',
s3Location: {
bucketName: 'bucketName',
objectKey: 'objectKey',
// the properties below are optional
objectVersion: 'objectVersion',
},
s3ObjectStorageMode: lambda.S3ObjectStorageMode.COPY,
sourceKMSKeyArn: 'sourceKMSKeyArn',
};
python
from aws_cdk.aws_s3 import Location
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_lambda as lambda_
code_config = lambda.CodeConfig(
image=lambda.CodeImageConfig(
image_uri="imageUri",
# the properties below are optional
cmd=["cmd"],
entrypoint=["entrypoint"],
working_directory="workingDirectory"
),
inline_code="inlineCode",
s3_location=Location(
bucket_name="bucketName",
object_key="objectKey",
# the properties below are optional
object_version="objectVersion"
),
s3_object_storage_mode=lambda_.S3ObjectStorageMode.COPY,
source_kms_key_arn="sourceKMSKeyArn"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.lambda.*;
CodeConfig codeConfig = CodeConfig.builder()
.image(CodeImageConfig.builder()
.imageUri("imageUri")
// the properties below are optional
.cmd(List.of("cmd"))
.entrypoint(List.of("entrypoint"))
.workingDirectory("workingDirectory")
.build())
.inlineCode("inlineCode")
.s3Location(Location.builder()
.bucketName("bucketName")
.objectKey("objectKey")
// the properties below are optional
.objectVersion("objectVersion")
.build())
.s3ObjectStorageMode(S3ObjectStorageMode.COPY)
.sourceKMSKeyArn("sourceKMSKeyArn")
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Lambda;
var codeConfig = new CodeConfig {
Image = new CodeImageConfig {
ImageUri = "imageUri",
// the properties below are optional
Cmd = new [] { "cmd" },
Entrypoint = new [] { "entrypoint" },
WorkingDirectory = "workingDirectory"
},
InlineCode = "inlineCode",
S3Location = new Location {
BucketName = "bucketName",
ObjectKey = "objectKey",
// the properties below are optional
ObjectVersion = "objectVersion"
},
S3ObjectStorageMode = S3ObjectStorageMode.COPY,
SourceKMSKeyArn = "sourceKMSKeyArn"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
codeConfig := &CodeConfig{
Image: &CodeImageConfig{
ImageUri: jsii.String("imageUri"),
// the properties below are optional
Cmd: []*string{
jsii.String("cmd"),
},
Entrypoint: []*string{
jsii.String("entrypoint"),
},
WorkingDirectory: jsii.String("workingDirectory"),
},
InlineCode: jsii.String("inlineCode"),
S3Location: &Location{
BucketName: jsii.String("bucketName"),
ObjectKey: jsii.String("objectKey"),
// the properties below are optional
ObjectVersion: jsii.String("objectVersion"),
},
S3ObjectStorageMode: awscdk.Aws_lambda.S3ObjectStorageMode_COPY,
SourceKMSKeyArn: jsii.String("sourceKMSKeyArn"),
}
Properties
imageoptionalCodeImageConfigimageoptionalCodeImageConfigimageoptionalCodeImageConfigImageoptionalCodeImageConfigImageoptionalCodeImageConfig#Docker image configuration (mutually exclusive with `s3Location` and `inlineCode`).
Default: code is not an ECR container image
inlineCodeoptionalstringinline_codeoptionalstrinlineCodeoptionalStringInlineCodeoptionalstringInlineCodeoptional*string#Inline code (mutually exclusive with `s3Location` and `image`).
Default: code is not inline code
s3LocationoptionalLocations3_locationoptionalLocations3LocationoptionalLocationS3LocationoptionalLocationS3LocationoptionalLocation#The location of the code in S3 (mutually exclusive with `inlineCode` and `image`).
Default: code is not an s3 location
s3ObjectStorageModeoptionalS3ObjectStorageModes3_object_storage_modeoptionalS3ObjectStorageModes3ObjectStorageModeoptionalS3ObjectStorageModeS3ObjectStorageModeoptionalS3ObjectStorageModeS3ObjectStorageModeoptionalS3ObjectStorageMode#How Lambda manages the storage of your code package.
Default: Lambda copies the deployment package from your S3 bucket into Lambda-managed storage.
sourceKMSKeyArnoptionalstringsource_kms_key_arnoptionalstrsourceKMSKeyArnoptionalStringSourceKMSKeyArnoptionalstringSourceKMSKeyArnoptional*string#The ARN of the KMS key that Lambda uses to encrypt the deployment package in Lambda-managed storage.
Default: Lambda uses an AWS owned key
This is not the key used to encrypt the source object in Amazon S3.