DockerImageCode — AWS Cloud Development Kit 1.204.0 documentation (original) (raw)
class aws_cdk.aws_lambda.DockerImageCode
Bases: object
Code property for the DockerImageFunction construct.
ExampleMetadata:
infused
Example:
lambda_.DockerImageFunction(self, "AssetFunction", code=lambda_.DockerImageCode.from_image_asset(path.join(__dirname, "docker-handler")) )
Static Methods
classmethod from_ecr(repository, *, cmd=None, entrypoint=None, tag=None, tag_or_digest=None, working_directory=None)
Use an existing ECR image as the Lambda code.
Parameters:
- repository (IRepository) – the ECR repository that the image is in.
- cmd (
Optional
[Sequence
[str
]]) – Specify or override the CMD on the specified Docker image or Dockerfile. This needs to be in the ‘exec form’, viz.,[ 'executable', 'param1', 'param2' ]
. Default: - use the CMD specified in the docker image or Dockerfile. - entrypoint (
Optional
[Sequence
[str
]]) – Specify or override the ENTRYPOINT on the specified Docker image or Dockerfile. An ENTRYPOINT allows you to configure a container that will run as an executable. This needs to be in the ‘exec form’, viz.,[ 'executable', 'param1', 'param2' ]
. Default: - use the ENTRYPOINT in the docker image or Dockerfile. - tag (
Optional
[str
]) – (deprecated) The image tag to use when pulling the image from ECR. Default: ‘latest’ - tag_or_digest (
Optional
[str
]) – The image tag or digest to use when pulling the image from ECR (digests must start withsha256:
). Default: ‘latest’ - working_directory (
Optional
[str
]) – Specify or override the WORKDIR on the specified Docker image or Dockerfile. A WORKDIR allows you to configure the working directory the container will use. Default: - use the WORKDIR in the docker image or Dockerfile.
Return type:
classmethod from_image_asset(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:
- directory (
str
) – the directory from which the asset must be created. - cmd (
Optional
[Sequence
[str
]]) – Specify or override the CMD on the specified Docker image or Dockerfile. This needs to be in the ‘exec form’, viz.,[ 'executable', 'param1', 'param2' ]
. Default: - use the CMD specified in the docker image or Dockerfile. - entrypoint (
Optional
[Sequence
[str
]]) – Specify or override the ENTRYPOINT on the specified Docker image or Dockerfile. An ENTRYPOINT allows you to configure a container that will run as an executable. This needs to be in the ‘exec form’, viz.,[ 'executable', 'param1', 'param2' ]
. Default: - use the ENTRYPOINT in the docker image or Dockerfile. - working_directory (
Optional
[str
]) – Specify or override the WORKDIR on the specified Docker image or Dockerfile. A WORKDIR allows you to configure the working directory the container will use. Default: - use the WORKDIR in the docker image or Dockerfile. - build_args (
Optional
[Mapping
[str
,str
]]) – Build args to pass to thedocker build
command. Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such aslambda.functionArn
orqueue.queueUrl
). Default: - no build args are passed - file (
Optional
[str
]) – Path to the Dockerfile (relative to the directory). Default: ‘Dockerfile’ - invalidation (
Union
[DockerImageAssetInvalidationOptions,Dict
[str
,Any
],None
]) – Options to control which parameters are used to invalidate the asset hash. Default: - hash all parameters - network_mode (
Optional
[NetworkMode]) – Networking mode for the RUN commands during build. Support docker API 1.25+. Default: - no networking mode specified (the default networking modeNetworkMode.DEFAULT
will be used) - platform (
Optional
[Platform]) – Platform to build for. Requires Docker Buildx. Default: - no platform specified (the current machine architecture will be used) - repository_name (
Optional
[str
]) – (deprecated) ECR repository name. Specify this property if you need to statically address the image, e.g. from a Kubernetes Pod. Note, this is only the repository name, without the registry and the tag parts. Default: - the default ECR repository for CDK assets - target (
Optional
[str
]) – Docker target to build to. Default: - no target - extra_hash (
Optional
[str
]) – (deprecated) Extra information to encode into the fingerprint (e.g. build instructions and other inputs). Default: - hash is only based on source content - exclude (
Optional
[Sequence
[str
]]) – (deprecated) Glob patterns to exclude from the copy. Default: nothing is excluded - follow (
Optional
[FollowMode]) – (deprecated) A strategy for how to handle symlinks. Default: Never - ignore_mode (
Optional
[IgnoreMode]) – (deprecated) The ignore behavior to use for exclude patterns. Default: - GLOB for file assets, DOCKER or GLOB for docker assets depending on whether the ‘ - follow_symlinks (
Optional
[SymlinkFollowMode]) – A strategy for how to handle symlinks. Default: SymlinkFollowMode.NEVER
Return type: