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.84.0 (build 5404dcf)", date="2023-06-19T16:30:47.277Z") @Stability(Stable) public abstract class ContainerImage extends software.amazon.jsii.JsiiObject
Constructs for types of container images.

Example:

 Vpc vpc;
 Cluster cluster = Cluster.Builder.create(this, "FargateCPCluster")
         .vpc(vpc)
         .enableFargateCapacityProviders(true)
         .build();
 FargateTaskDefinition taskDefinition = new FargateTaskDefinition(this, "TaskDef");
 taskDefinition.addContainer("web", ContainerDefinitionOptions.builder()
         .image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
         .build());
 FargateService.Builder.create(this, "FargateService")
         .cluster(cluster)
         .taskDefinition(taskDefinition)
         .capacityProviderStrategies(List.of(CapacityProviderStrategy.builder()
                 .capacityProvider("FARGATE_SPOT")
                 .weight(2)
                 .build(), CapacityProviderStrategy.builder()
                 .capacityProvider("FARGATE")
                 .weight(1)
                 .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 -
    • 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 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.