EcrImage Class
An image from an Amazon ECR repository.
Example
ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecr_assets as ecr_assets } from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';
declare const dockerImageAsset: ecr_assets.DockerImageAsset;
const ecrImage = ecs.EcrImage.fromDockerImageAsset(dockerImageAsset);
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecr_assets as ecr_assets
from aws_cdk import aws_ecs as ecs
# docker_image_asset: ecr_assets.DockerImageAsset
ecr_image = ecs.EcrImage.from_docker_image_asset(docker_image_asset)
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.ecr.assets.*;
import software.amazon.awscdk.services.ecs.*;
DockerImageAsset dockerImageAsset;
ContainerImage ecrImage = EcrImage.fromDockerImageAsset(dockerImageAsset);
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.Ecr.Assets;
using Amazon.CDK.AWS.ECS;
DockerImageAsset dockerImageAsset;
var ecrImage = EcrImage.FromDockerImageAsset(dockerImageAsset);
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"
import "github.com/aws/aws-cdk-go/awscdk"
var dockerImageAsset DockerImageAsset
ecrImage := awscdk.Aws_ecs.EcrImage_FromDockerImageAsset(dockerImageAsset)
Initializer
ts
new EcrImage(repository: IRepository, tagOrDigest: string)
python
EcrImage(repository: IRepository, tag_or_digest: str)
java
new EcrImage(IRepository repository, String tagOrDigest)
csharp
new EcrImage(IRepository repository, string tagOrDigest)
go
NewEcrImage(Repository IRepository, TagOrDigest *string)
Properties
The image name. Images in Amazon ECR repositories can be specified by either using the full registry/repository:tag or registry/repository@digest.
For example, 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>:latest or 012345678910.dkr.ecr.<region-name>.amazonaws.com/<repository-name>@sha256:94afd1f2e64d908bc90dbca0035a5b567EXAMPLE.
Methods
bind(_scope: Construct, containerDefinition: ContainerDefinition): ContainerImageConfigdef bind(self, _scope: Construct, container_definition: ContainerDefinition) -> ContainerImageConfigpublic ContainerImageConfig bind(Construct _scope, ContainerDefinition containerDefinition)public ContainerImageConfig Bind(Construct _scope, ContainerDefinition containerDefinition)func Bind(_scope Construct, ContainerDefinition ContainerDefinition) ContainerImageConfig#Called when the image is used by a ContainerDefinition.
fromAsset(directory: string, props?: AssetImageProps): AssetImage@staticmethod def from_asset(directory: str, props: typing.Optional[AssetImageProps] = None) -> AssetImagepublic static AssetImage fromAsset(String directory, AssetImageProps props)public static AssetImage FromAsset(string directory, AssetImageProps? props = null)func FromAsset(Directory *string, Props AssetImageProps) AssetImagestatic#Reference an image that's constructed directly from sources on disk.
If you already have a DockerImageAsset instance, you can use the ContainerImage.fromDockerImageAsset method instead.
1 parameter
Parameters
directorydirectorydirectorydirectoryDirectory— The directory containing the Dockerfile.
fromDockerImageAsset(asset: DockerImageAsset): ContainerImage@staticmethod def from_docker_image_asset(asset: DockerImageAsset) -> ContainerImagepublic static ContainerImage fromDockerImageAsset(DockerImageAsset asset)public static ContainerImage FromDockerImageAsset(DockerImageAsset asset)func FromDockerImageAsset(Asset DockerImageAsset) ContainerImagestatic#Use an existing `DockerImageAsset` for this container image.
1 parameter
Parameters
assetassetassetassetAsset— TheDockerImageAssetto use for this container definition.
fromEcrRepository(repository: IRepository, tag?: string): EcrImage // chainable@staticmethod def from_ecr_repository(repository: IRepository, tag: typing.Optional[str] = None) -> EcrImagepublic static EcrImage fromEcrRepository(IRepository repository, String tag)public static EcrImage FromEcrRepository(IRepository repository, string? tag = null)func FromEcrRepository(Repository IRepository, Tag *string) EcrImagestatic#Reference an image in an ECR repository.
1 parameter
Parameters
tagtagtagtagTag— If you don't specify this parameter,latestis used as default.
fromRegistry(name: string, props?: RepositoryImageProps): RepositoryImage@staticmethod def from_registry(name: str, props: typing.Optional[RepositoryImageProps] = None) -> RepositoryImagepublic static RepositoryImage fromRegistry(String name, RepositoryImageProps props)public static RepositoryImage FromRegistry(string name, RepositoryImageProps? props = null)func FromRegistry(Name *string, Props RepositoryImageProps) RepositoryImagestatic#Reference an image on DockerHub or another online registry.
fromTarball(tarballFile: string): ContainerImage@staticmethod def from_tarball(tarball_file: str) -> ContainerImagepublic static ContainerImage fromTarball(String tarballFile)public static ContainerImage FromTarball(string tarballFile)func FromTarball(TarballFile *string) ContainerImagestatic#Use an existing tarball for this container image.
Use this method if the container image has already been created by another process (e.g. jib) and you want to add it as a container image asset.
1 parameter
Parameters
tarballFiletarball_filetarballFiletarballFileTarballFile— Absolute path to the tarball.