Class ContainerDefinition.Builder

java.lang.Object
software.amazon.awscdk.services.ecs.ContainerDefinition.Builder
All Implemented Interfaces:
software.amazon.jsii.Builder<ContainerDefinition>
Enclosing class:
ContainerDefinition

@Stability(Stable) public static final class ContainerDefinition.Builder extends Object implements software.amazon.jsii.Builder<ContainerDefinition>
A fluent builder for ContainerDefinition.
  • Method Details

    • create

      @Stability(Stable) public static ContainerDefinition.Builder create(software.constructs.Construct scope, String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      Returns:
      a new instance of ContainerDefinition.Builder.
    • image

      @Stability(Stable) public ContainerDefinition.Builder image(ContainerImage image)
      The image used to start a container.

      This string is passed directly to the Docker daemon. Images in the Docker Hub registry are available by default. Other repositories are specified with either repository-url/image:tag or repository-url/image@digest. TODO: Update these to specify using classes of IContainerImage

      Parameters:
      image - The image used to start a container. This parameter is required.
      Returns:
      this
    • command

      @Stability(Stable) public ContainerDefinition.Builder command(List<String> command)
      The command that is passed to the container.

      If you provide a shell command as a single string, you have to quote command-line arguments.

      Default: - CMD value built into container image.

      Parameters:
      command - The command that is passed to the container. This parameter is required.
      Returns:
      this
    • containerName

      @Stability(Stable) public ContainerDefinition.Builder containerName(String containerName)
      The name of the container.

      Default: - id of node associated with ContainerDefinition.

      Parameters:
      containerName - The name of the container. This parameter is required.
      Returns:
      this
    • cpu

      @Stability(Stable) public ContainerDefinition.Builder cpu(Number cpu)
      The minimum number of CPU units to reserve for the container.

      Default: - No minimum CPU units reserved.

      Parameters:
      cpu - The minimum number of CPU units to reserve for the container. This parameter is required.
      Returns:
      this
    • disableNetworking

      @Stability(Stable) public ContainerDefinition.Builder disableNetworking(Boolean disableNetworking)
      Specifies whether networking is disabled within the container.

      When this parameter is true, networking is disabled within the container.

      Default: false

      Parameters:
      disableNetworking - Specifies whether networking is disabled within the container. This parameter is required.
      Returns:
      this
    • dnsSearchDomains

      @Stability(Stable) public ContainerDefinition.Builder dnsSearchDomains(List<String> dnsSearchDomains)
      A list of DNS search domains that are presented to the container.

      Default: - No search domains.

      Parameters:
      dnsSearchDomains - A list of DNS search domains that are presented to the container. This parameter is required.
      Returns:
      this
    • dnsServers

      @Stability(Stable) public ContainerDefinition.Builder dnsServers(List<String> dnsServers)
      A list of DNS servers that are presented to the container.

      Default: - Default DNS servers.

      Parameters:
      dnsServers - A list of DNS servers that are presented to the container. This parameter is required.
      Returns:
      this
    • dockerLabels

      @Stability(Stable) public ContainerDefinition.Builder dockerLabels(Map<String,String> dockerLabels)
      A key/value map of labels to add to the container.

      Default: - No labels.

      Parameters:
      dockerLabels - A key/value map of labels to add to the container. This parameter is required.
      Returns:
      this
    • dockerSecurityOptions

      @Stability(Stable) public ContainerDefinition.Builder dockerSecurityOptions(List<String> dockerSecurityOptions)
      A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems.

      Default: - No security labels.

      Parameters:
      dockerSecurityOptions - A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems. This parameter is required.
      Returns:
      this
    • entryPoint

      @Stability(Stable) public ContainerDefinition.Builder entryPoint(List<String> entryPoint)
      The ENTRYPOINT value to pass to the container.

      Default: - Entry point configured in container.

      Parameters:
      entryPoint - The ENTRYPOINT value to pass to the container. This parameter is required.
      Returns:
      this
      See Also:
    • environment

      @Stability(Stable) public ContainerDefinition.Builder environment(Map<String,String> environment)
      The environment variables to pass to the container.

      Default: - No environment variables.

      Parameters:
      environment - The environment variables to pass to the container. This parameter is required.
      Returns:
      this
    • environmentFiles

      @Stability(Stable) public ContainerDefinition.Builder environmentFiles(List<? extends EnvironmentFile> environmentFiles)
      The environment files to pass to the container.

      Default: - No environment files.

      Parameters:
      environmentFiles - The environment files to pass to the container. This parameter is required.
      Returns:
      this
      See Also:
    • essential

      @Stability(Stable) public ContainerDefinition.Builder essential(Boolean essential)
      Specifies whether the container is marked essential.

      If the essential parameter of a container is marked as true, and that container fails or stops for any reason, all other containers that are part of the task are stopped. If the essential parameter of a container is marked as false, then its failure does not affect the rest of the containers in a task. All tasks must have at least one essential container.

      If this parameter is omitted, a container is assumed to be essential.

      Default: true

      Parameters:
      essential - Specifies whether the container is marked essential. This parameter is required.
      Returns:
      this
    • extraHosts

      @Stability(Stable) public ContainerDefinition.Builder extraHosts(Map<String,String> extraHosts)
      A list of hostnames and IP address mappings to append to the /etc/hosts file on the container.

      Default: - No extra hosts.

      Parameters:
      extraHosts - A list of hostnames and IP address mappings to append to the /etc/hosts file on the container. This parameter is required.
      Returns:
      this
    • gpuCount

      @Stability(Stable) public ContainerDefinition.Builder gpuCount(Number gpuCount)
      The number of GPUs assigned to the container.

      Default: - No GPUs assigned.

      Parameters:
      gpuCount - The number of GPUs assigned to the container. This parameter is required.
      Returns:
      this
    • healthCheck

      @Stability(Stable) public ContainerDefinition.Builder healthCheck(HealthCheck healthCheck)
      The health check command and associated configuration parameters for the container.

      Default: - Health check configuration from container.

      Parameters:
      healthCheck - The health check command and associated configuration parameters for the container. This parameter is required.
      Returns:
      this
    • hostname

      @Stability(Stable) public ContainerDefinition.Builder hostname(String hostname)
      The hostname to use for your container.

      Default: - Automatic hostname.

      Parameters:
      hostname - The hostname to use for your container. This parameter is required.
      Returns:
      this
    • inferenceAcceleratorResources

      @Stability(Stable) public ContainerDefinition.Builder inferenceAcceleratorResources(List<String> inferenceAcceleratorResources)
      The inference accelerators referenced by the container.

      Default: - No inference accelerators assigned.

      Parameters:
      inferenceAcceleratorResources - The inference accelerators referenced by the container. This parameter is required.
      Returns:
      this
    • linuxParameters

      @Stability(Stable) public ContainerDefinition.Builder linuxParameters(LinuxParameters linuxParameters)
      Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.

      For more information see KernelCapabilities.

      Default: - No Linux parameters.

      Parameters:
      linuxParameters - Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. This parameter is required.
      Returns:
      this
    • logging

      @Stability(Stable) public ContainerDefinition.Builder logging(LogDriver logging)
      The log configuration specification for the container.

      Default: - Containers use the same logging driver that the Docker daemon uses.

      Parameters:
      logging - The log configuration specification for the container. This parameter is required.
      Returns:
      this
    • memoryLimitMiB

      @Stability(Stable) public ContainerDefinition.Builder memoryLimitMiB(Number memoryLimitMiB)
      The amount (in MiB) of memory to present to the container.

      If your container attempts to exceed the allocated memory, the container is terminated.

      At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

      Default: - No memory limit.

      Parameters:
      memoryLimitMiB - The amount (in MiB) of memory to present to the container. This parameter is required.
      Returns:
      this
    • memoryReservationMiB

      @Stability(Stable) public ContainerDefinition.Builder memoryReservationMiB(Number memoryReservationMiB)
      The soft limit (in MiB) of memory to reserve for the container.

      When system memory is under heavy contention, Docker attempts to keep the container memory to this soft limit. However, your container can consume more memory when it needs to, up to either the hard limit specified with the memory parameter (if applicable), or all of the available memory on the container instance, whichever comes first.

      At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

      Default: - No memory reserved.

      Parameters:
      memoryReservationMiB - The soft limit (in MiB) of memory to reserve for the container. This parameter is required.
      Returns:
      this
    • portMappings

      @Stability(Stable) public ContainerDefinition.Builder portMappings(List<? extends PortMapping> portMappings)
      The port mappings to add to the container definition.

      Default: - No ports are mapped.

      Parameters:
      portMappings - The port mappings to add to the container definition. This parameter is required.
      Returns:
      this
    • privileged

      @Stability(Stable) public ContainerDefinition.Builder privileged(Boolean privileged)
      Specifies whether the container is marked as privileged.

      When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user).

      Default: false

      Parameters:
      privileged - Specifies whether the container is marked as privileged. This parameter is required.
      Returns:
      this
    • readonlyRootFilesystem

      @Stability(Stable) public ContainerDefinition.Builder readonlyRootFilesystem(Boolean readonlyRootFilesystem)
      When this parameter is true, the container is given read-only access to its root file system.

      Default: false

      Parameters:
      readonlyRootFilesystem - When this parameter is true, the container is given read-only access to its root file system. This parameter is required.
      Returns:
      this
    • secrets

      @Stability(Stable) public ContainerDefinition.Builder secrets(Map<String,? extends Secret> secrets)
      The secret environment variables to pass to the container.

      Default: - No secret environment variables.

      Parameters:
      secrets - The secret environment variables to pass to the container. This parameter is required.
      Returns:
      this
    • startTimeout

      @Stability(Stable) public ContainerDefinition.Builder startTimeout(Duration startTimeout)
      Time duration (in seconds) to wait before giving up on resolving dependencies for a container.

      Default: - none

      Parameters:
      startTimeout - Time duration (in seconds) to wait before giving up on resolving dependencies for a container. This parameter is required.
      Returns:
      this
    • stopTimeout

      @Stability(Stable) public ContainerDefinition.Builder stopTimeout(Duration stopTimeout)
      Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own.

      Default: - none

      Parameters:
      stopTimeout - Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own. This parameter is required.
      Returns:
      this
    • systemControls

      @Stability(Stable) public ContainerDefinition.Builder systemControls(List<? extends SystemControl> systemControls)
      A list of namespaced kernel parameters to set in the container.

      Default: - No system controls are set.

      Parameters:
      systemControls - A list of namespaced kernel parameters to set in the container. This parameter is required.
      Returns:
      this
      See Also:
    • user

      @Stability(Stable) public ContainerDefinition.Builder user(String user)
      The user name to use inside the container.

      Default: root

      Parameters:
      user - The user name to use inside the container. This parameter is required.
      Returns:
      this
    • workingDirectory

      @Stability(Stable) public ContainerDefinition.Builder workingDirectory(String workingDirectory)
      The working directory in which to run commands inside the container.

      Default: /

      Parameters:
      workingDirectory - The working directory in which to run commands inside the container. This parameter is required.
      Returns:
      this
    • taskDefinition

      @Stability(Stable) public ContainerDefinition.Builder taskDefinition(TaskDefinition taskDefinition)
      The name of the task definition that includes this container definition.

      [disable-awslint:ref-via-interface]

      Parameters:
      taskDefinition - The name of the task definition that includes this container definition. This parameter is required.
      Returns:
      this
    • build

      @Stability(Stable) public ContainerDefinition build()
      Specified by:
      build in interface software.amazon.jsii.Builder<ContainerDefinition>
      Returns:
      a newly built instance of ContainerDefinition.