S3Code — AWS Cloud Development Kit 1.204.0 documentation (original) (raw)

AWS Cloud Development Kit

class aws_cdk.aws_lambda.S3Code(bucket, key, object_version=None)

Bases: Code

Lambda code from an S3 archive.

ExampleMetadata:

fixture=_generated

Example:

The code below shows an example of how to instantiate this type.

The values are placeholders you should change.

import aws_cdk.aws_lambda as lambda_ import aws_cdk.aws_s3 as s3

bucket: s3.Bucket

s3_code = lambda_.S3Code(bucket, "key", "objectVersion")

Parameters:

Methods

bind(_scope)

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

Parameters:

_scope (Construct)

Return type:

CodeConfig

bind_to_resource(_resource, *, resource_property=None)

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:

Return type:

None

Attributes

is_inline

Determines whether this Code is inline code or not.

Static Methods

classmethod asset(path)

(deprecated) DEPRECATED.

Parameters:

path (str)

Deprecated:

use fromAsset

Stability:

deprecated

Return type:

AssetCode

classmethod bucket(bucket, key, object_version=None)

(deprecated) DEPRECATED.

Parameters:

Deprecated:

use fromBucket

Stability:

deprecated

Return type:

S3Code

classmethod cfn_parameters(*, bucket_name_param=None, object_key_param=None)

(deprecated) DEPRECATED.

Parameters:

Deprecated:

use fromCfnParameters

Stability:

deprecated

Return type:

CfnParametersCode

classmethod from_asset(path, *, readers=None, source_hash=None, exclude=None, follow=None, ignore_mode=None, follow_symlinks=None, asset_hash=None, asset_hash_type=None, bundling=None)

Loads the function code from a local disk path.

Parameters:

Return type:

AssetCode

classmethod from_asset_image(directory, *, cmd=None, entrypoint=None, working_directory=None, build_args=None, file=None, invalidation=None, network_mode=None, platform=None, repository_name=None, target=None, extra_hash=None, exclude=None, follow=None, ignore_mode=None, follow_symlinks=None)

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

Parameters:

Return type:

AssetImageCode

classmethod from_bucket(bucket, key, object_version=None)

Lambda handler code as an S3 object.

Parameters:

Return type:

S3Code

classmethod from_cfn_parameters(*, bucket_name_param=None, object_key_param=None)

Creates a new Lambda source defined using CloudFormation parameters.

Parameters:

Return type:

CfnParametersCode

Returns:

a new instance of CfnParametersCode

classmethod from_docker_build(path, *, image_path=None, output_path=None, build_args=None, file=None, platform=None)

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

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

Parameters:

Return type:

AssetCode

classmethod from_ecr_image(repository, *, cmd=None, entrypoint=None, tag=None, tag_or_digest=None, working_directory=None)

Use an existing ECR image as the Lambda code.

Parameters:

Return type:

EcrImageCode

classmethod from_inline(code)

Inline code for Lambda handler.

Parameters:

code (str) – The actual handler code (limited to 4KiB).

Return type:

InlineCode

Returns:

LambdaInlineCode with inline code.

classmethod inline(code)

(deprecated) DEPRECATED.

Parameters:

code (str)

Deprecated:

use fromInline

Stability:

deprecated

Return type:

InlineCode