Class ContainerImage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ecs.ContainerImage
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Direct Known Subclasses:
AssetImage, EcrImage, RepositoryImage, TagParameterContainerImage

@Generated(value="jsii-pacmak/1.102.0 (build e354887)", date="2024-09-10T01:10:08.811Z") @Stability(Stable) public abstract class ContainerImage extends software.amazon.jsii.JsiiObject
Constructs for types of container images.

Example:

 ISecret mySecret;
 EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
         .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
                 .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
                 .memory(Size.mebibytes(2048))
                 .cpu(256)
                 .secrets(Map.of(
                         "MY_SECRET_ENV_VAR", Secret.fromSecretsManager(mySecret)))
                 .build())
         .build();
 
  • Constructor Details

    • ContainerImage

      protected ContainerImage(software.amazon.jsii.JsiiObjectRef objRef)
    • ContainerImage

      protected ContainerImage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • ContainerImage

      @Stability(Stable) protected ContainerImage()
  • Method Details

    • fromAsset

      @Stability(Stable) @NotNull public static AssetImage fromAsset(@NotNull String directory, @Nullable AssetImageProps props)
      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.

      Parameters:
      directory - The directory containing the Dockerfile. This parameter is required.
      props -
    • fromAsset

      @Stability(Stable) @NotNull public static AssetImage fromAsset(@NotNull String directory)
      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.

      Parameters:
      directory - The directory containing the Dockerfile. This parameter is required.
    • fromDockerImageAsset

      @Stability(Stable) @NotNull public static ContainerImage fromDockerImageAsset(@NotNull DockerImageAsset asset)
      Use an existing DockerImageAsset for this container image.

      Parameters:
      asset - The DockerImageAsset to use for this container definition. This parameter is required.
    • fromEcrRepository

      @Stability(Stable) @NotNull public static EcrImage fromEcrRepository(@NotNull IRepository repository, @Nullable String tag)
      Reference an image in an ECR repository.

      Parameters:
      repository - This parameter is required.
      tag - If you don't specify this parameter, latest is used as default.
    • fromEcrRepository

      @Stability(Stable) @NotNull public static EcrImage fromEcrRepository(@NotNull IRepository repository)
      Reference an image in an ECR repository.

      Parameters:
      repository - This parameter is required.
    • fromRegistry

      @Stability(Stable) @NotNull public static RepositoryImage fromRegistry(@NotNull String name, @Nullable RepositoryImageProps props)
      Reference an image on DockerHub or another online registry.

      Parameters:
      name - This parameter is required.
      props -
    • fromRegistry

      @Stability(Stable) @NotNull public static RepositoryImage fromRegistry(@NotNull String name)
      Reference an image on DockerHub or another online registry.

      Parameters:
      name - This parameter is required.
    • fromTarball

      @Stability(Stable) @NotNull public static ContainerImage fromTarball(@NotNull String tarballFile)
      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.

      Parameters:
      tarballFile - Absolute path to the tarball. This parameter is required.
    • bind

      @Stability(Stable) @NotNull public abstract ContainerImageConfig bind(@NotNull software.constructs.Construct scope, @NotNull ContainerDefinition containerDefinition)
      Called when the image is used by a ContainerDefinition.

      Parameters:
      scope - This parameter is required.
      containerDefinition - This parameter is required.