# DockerImageCode

Code property for the DockerImageFunction construct.

Obtainable from: DockerImageCode.fromEcr, DockerImageCode.fromImageAsset

- Source: [`aws-lambda/lib/image-function.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-lambda/lib/image-function.ts#L29)

## Example

TypeScript:

```ts
new lambda.DockerImageFunction(this, 'AssetFunction', {
  code: lambda.DockerImageCode.fromImageAsset(path.join(__dirname, 'docker-arm64-handler')),
  architecture: lambda.Architecture.ARM_64,
});
```

Python:

```python
lambda_.DockerImageFunction(self, "AssetFunction",
    code=lambda_.DockerImageCode.from_image_asset(path.join(__dirname, "docker-arm64-handler")),
    architecture=lambda_.Architecture.ARM_64
)
```

Java:

```java
DockerImageFunction.Builder.create(this, "AssetFunction")
        .code(DockerImageCode.fromImageAsset(join(__dirname, "docker-arm64-handler")))
        .architecture(Architecture.ARM_64)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
new DockerImageFunction(this, "AssetFunction", new DockerImageFunctionProps {
    Code = DockerImageCode.FromImageAsset(Join(__dirname, "docker-arm64-handler")),
    Architecture = Architecture.ARM_64
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
lambda.NewDockerImageFunction(this, jsii.String("AssetFunction"), &DockerImageFunctionProps{
	Code: lambda.DockerImageCode_FromImageAsset(path.join(__dirname, jsii.String("docker-arm64-handler"))),
	Architecture: lambda.Architecture_ARM_64(),
})
```

## Initializer

TypeScript:

```ts
new DockerImageCode()
```

Python:

```python
DockerImageCode()
```

Java:

```java
new DockerImageCode()
```

C# / .NET:

```csharp
new DockerImageCode()
```

Golang:

```go
NewDockerImageCode()
```

## Methods

- `fromEcr(repository: IRepository, props?: EcrImageCodeProps): DockerImageCode // chainable` (static) — Use an existing ECR image as the Lambda code.

  **Parameters**

  - `repository` — the ECR repository that the image is in.
  - `props` — properties to further configure the selected image.

- `fromImageAsset(directory: string, props?: AssetImageCodeProps): DockerImageCode // chainable` (static) — Create an ECR image from the specified asset and bind it as the Lambda code.

  **Parameters**

  - `directory` — the directory from which the asset must be created.
  - `props` — properties to further configure the selected image.
