Class ContainerDefinitionProps.Builder
- All Implemented Interfaces:
software.amazon.jsii.Builder<ContainerDefinitionProps>
- Enclosing interface:
ContainerDefinitionProps
ContainerDefinitionProps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds the configured instance.Sets the value ofContainerDefinitionOptions.getCommand()
containerName
(String containerName) Sets the value ofContainerDefinitionOptions.getContainerName()
Sets the value ofContainerDefinitionOptions.getCpu()
credentialSpecs
(List<? extends CredentialSpec> credentialSpecs) Sets the value ofContainerDefinitionOptions.getCredentialSpecs()
disableNetworking
(Boolean disableNetworking) Sets the value ofContainerDefinitionOptions.getDisableNetworking()
dnsSearchDomains
(List<String> dnsSearchDomains) Sets the value ofContainerDefinitionOptions.getDnsSearchDomains()
dnsServers
(List<String> dnsServers) Sets the value ofContainerDefinitionOptions.getDnsServers()
dockerLabels
(Map<String, String> dockerLabels) Sets the value ofContainerDefinitionOptions.getDockerLabels()
dockerSecurityOptions
(List<String> dockerSecurityOptions) Sets the value ofContainerDefinitionOptions.getDockerSecurityOptions()
enableRestartPolicy
(Boolean enableRestartPolicy) Sets the value ofContainerDefinitionOptions.getEnableRestartPolicy()
entryPoint
(List<String> entryPoint) Sets the value ofContainerDefinitionOptions.getEntryPoint()
environment
(Map<String, String> environment) Sets the value ofContainerDefinitionOptions.getEnvironment()
environmentFiles
(List<? extends EnvironmentFile> environmentFiles) Sets the value ofContainerDefinitionOptions.getEnvironmentFiles()
Sets the value ofContainerDefinitionOptions.getEssential()
extraHosts
(Map<String, String> extraHosts) Sets the value ofContainerDefinitionOptions.getExtraHosts()
Sets the value ofContainerDefinitionOptions.getGpuCount()
healthCheck
(HealthCheck healthCheck) Sets the value ofContainerDefinitionOptions.getHealthCheck()
Sets the value ofContainerDefinitionOptions.getHostname()
image
(ContainerImage image) Sets the value ofContainerDefinitionOptions.getImage()
inferenceAcceleratorResources
(List<String> inferenceAcceleratorResources) Sets the value ofContainerDefinitionOptions.getInferenceAcceleratorResources()
interactive
(Boolean interactive) Sets the value ofContainerDefinitionOptions.getInteractive()
linuxParameters
(LinuxParameters linuxParameters) Sets the value ofContainerDefinitionOptions.getLinuxParameters()
Sets the value ofContainerDefinitionOptions.getLogging()
memoryLimitMiB
(Number memoryLimitMiB) Sets the value ofContainerDefinitionOptions.getMemoryLimitMiB()
memoryReservationMiB
(Number memoryReservationMiB) Sets the value ofContainerDefinitionOptions.getMemoryReservationMiB()
portMappings
(List<? extends PortMapping> portMappings) Sets the value ofContainerDefinitionOptions.getPortMappings()
privileged
(Boolean privileged) Sets the value ofContainerDefinitionOptions.getPrivileged()
pseudoTerminal
(Boolean pseudoTerminal) Sets the value ofContainerDefinitionOptions.getPseudoTerminal()
readonlyRootFilesystem
(Boolean readonlyRootFilesystem) Sets the value ofContainerDefinitionOptions.getReadonlyRootFilesystem()
restartAttemptPeriod
(Duration restartAttemptPeriod) Sets the value ofContainerDefinitionOptions.getRestartAttemptPeriod()
restartIgnoredExitCodes
(List<? extends Number> restartIgnoredExitCodes) Sets the value ofContainerDefinitionOptions.getRestartIgnoredExitCodes()
Sets the value ofContainerDefinitionOptions.getSecrets()
startTimeout
(Duration startTimeout) Sets the value ofContainerDefinitionOptions.getStartTimeout()
stopTimeout
(Duration stopTimeout) Sets the value ofContainerDefinitionOptions.getStopTimeout()
systemControls
(List<? extends SystemControl> systemControls) Sets the value ofContainerDefinitionOptions.getSystemControls()
taskDefinition
(TaskDefinition taskDefinition) Sets the value ofContainerDefinitionProps.getTaskDefinition()
Sets the value ofContainerDefinitionOptions.getUlimits()
Sets the value ofContainerDefinitionOptions.getUser()
workingDirectory
(String workingDirectory) Sets the value ofContainerDefinitionOptions.getWorkingDirectory()
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
taskDefinition
@Stability(Stable) public ContainerDefinitionProps.Builder taskDefinition(TaskDefinition taskDefinition) Sets the value ofContainerDefinitionProps.getTaskDefinition()
- Parameters:
taskDefinition
- The name of the task definition that includes this container definition. This parameter is required. [disable-awslint:ref-via-interface]- Returns:
this
-
image
Sets the value ofContainerDefinitionOptions.getImage()
- Parameters:
image
- The image used to start a container. This parameter is required. 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- Returns:
this
-
command
Sets the value ofContainerDefinitionOptions.getCommand()
- Parameters:
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.- Returns:
this
-
containerName
Sets the value ofContainerDefinitionOptions.getContainerName()
- Parameters:
containerName
- The name of the container.- Returns:
this
-
cpu
Sets the value ofContainerDefinitionOptions.getCpu()
- Parameters:
cpu
- The minimum number of CPU units to reserve for the container.- Returns:
this
-
credentialSpecs
@Stability(Stable) public ContainerDefinitionProps.Builder credentialSpecs(List<? extends CredentialSpec> credentialSpecs) Sets the value ofContainerDefinitionOptions.getCredentialSpecs()
- Parameters:
credentialSpecs
- A list of ARNs in SSM or Amazon S3 to a credential spec (CredSpec
) file that configures the container for Active Directory authentication. We recommend that you use this parameter instead of thedockerSecurityOptions
.Currently, only one credential spec is allowed per container definition.
- Returns:
this
-
disableNetworking
@Stability(Stable) public ContainerDefinitionProps.Builder disableNetworking(Boolean disableNetworking) Sets the value ofContainerDefinitionOptions.getDisableNetworking()
- Parameters:
disableNetworking
- Specifies whether networking is disabled within the container. When this parameter is true, networking is disabled within the container.- Returns:
this
-
dnsSearchDomains
@Stability(Stable) public ContainerDefinitionProps.Builder dnsSearchDomains(List<String> dnsSearchDomains) Sets the value ofContainerDefinitionOptions.getDnsSearchDomains()
- Parameters:
dnsSearchDomains
- A list of DNS search domains that are presented to the container.- Returns:
this
-
dnsServers
Sets the value ofContainerDefinitionOptions.getDnsServers()
- Parameters:
dnsServers
- A list of DNS servers that are presented to the container.- Returns:
this
-
dockerLabels
@Stability(Stable) public ContainerDefinitionProps.Builder dockerLabels(Map<String, String> dockerLabels) Sets the value ofContainerDefinitionOptions.getDockerLabels()
- Parameters:
dockerLabels
- A key/value map of labels to add to the container.- Returns:
this
-
dockerSecurityOptions
@Stability(Stable) public ContainerDefinitionProps.Builder dockerSecurityOptions(List<String> dockerSecurityOptions) Sets the value ofContainerDefinitionOptions.getDockerSecurityOptions()
- Parameters:
dockerSecurityOptions
- A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems.- Returns:
this
-
enableRestartPolicy
@Stability(Stable) public ContainerDefinitionProps.Builder enableRestartPolicy(Boolean enableRestartPolicy) Sets the value ofContainerDefinitionOptions.getEnableRestartPolicy()
- Parameters:
enableRestartPolicy
- Enable a restart policy for a container. When you set up a restart policy, Amazon ECS can restart the container without needing to replace the task.- Returns:
this
-
entryPoint
Sets the value ofContainerDefinitionOptions.getEntryPoint()
- Parameters:
entryPoint
- The ENTRYPOINT value to pass to the container.- Returns:
this
-
environment
@Stability(Stable) public ContainerDefinitionProps.Builder environment(Map<String, String> environment) Sets the value ofContainerDefinitionOptions.getEnvironment()
- Parameters:
environment
- The environment variables to pass to the container.- Returns:
this
-
environmentFiles
@Stability(Stable) public ContainerDefinitionProps.Builder environmentFiles(List<? extends EnvironmentFile> environmentFiles) Sets the value ofContainerDefinitionOptions.getEnvironmentFiles()
- Parameters:
environmentFiles
- The environment files to pass to the container.- Returns:
this
-
essential
Sets the value ofContainerDefinitionOptions.getEssential()
- Parameters:
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.
- Returns:
this
-
extraHosts
@Stability(Stable) public ContainerDefinitionProps.Builder extraHosts(Map<String, String> extraHosts) Sets the value ofContainerDefinitionOptions.getExtraHosts()
- Parameters:
extraHosts
- A list of hostnames and IP address mappings to append to the /etc/hosts file on the container.- Returns:
this
-
gpuCount
Sets the value ofContainerDefinitionOptions.getGpuCount()
- Parameters:
gpuCount
- The number of GPUs assigned to the container.- Returns:
this
-
healthCheck
Sets the value ofContainerDefinitionOptions.getHealthCheck()
- Parameters:
healthCheck
- The health check command and associated configuration parameters for the container.- Returns:
this
-
hostname
Sets the value ofContainerDefinitionOptions.getHostname()
- Parameters:
hostname
- The hostname to use for your container.- Returns:
this
-
inferenceAcceleratorResources
@Stability(Stable) public ContainerDefinitionProps.Builder inferenceAcceleratorResources(List<String> inferenceAcceleratorResources) Sets the value ofContainerDefinitionOptions.getInferenceAcceleratorResources()
- Parameters:
inferenceAcceleratorResources
- The inference accelerators referenced by the container.- Returns:
this
-
interactive
Sets the value ofContainerDefinitionOptions.getInteractive()
- Parameters:
interactive
- When this parameter is true, you can deploy containerized applications that require stdin or a tty to be allocated.- Returns:
this
-
linuxParameters
@Stability(Stable) public ContainerDefinitionProps.Builder linuxParameters(LinuxParameters linuxParameters) Sets the value ofContainerDefinitionOptions.getLinuxParameters()
- Parameters:
linuxParameters
- Linux-specific modifications that are applied to the container, such as Linux kernel capabilities. For more information see KernelCapabilities.- Returns:
this
-
logging
Sets the value ofContainerDefinitionOptions.getLogging()
- Parameters:
logging
- The log configuration specification for the container.- Returns:
this
-
memoryLimitMiB
Sets the value ofContainerDefinitionOptions.getMemoryLimitMiB()
- Parameters:
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.
- Returns:
this
-
memoryReservationMiB
@Stability(Stable) public ContainerDefinitionProps.Builder memoryReservationMiB(Number memoryReservationMiB) Sets the value ofContainerDefinitionOptions.getMemoryReservationMiB()
- Parameters:
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.
- Returns:
this
-
portMappings
@Stability(Stable) public ContainerDefinitionProps.Builder portMappings(List<? extends PortMapping> portMappings) Sets the value ofContainerDefinitionOptions.getPortMappings()
- Parameters:
portMappings
- The port mappings to add to the container definition.- Returns:
this
-
privileged
Sets the value ofContainerDefinitionOptions.getPrivileged()
- Parameters:
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).- Returns:
this
-
pseudoTerminal
Sets the value ofContainerDefinitionOptions.getPseudoTerminal()
- Parameters:
pseudoTerminal
- When this parameter is true, a TTY is allocated. This parameter maps to Tty in the "Create a container section" of the Docker Remote API and the --tty option todocker run
.- Returns:
this
-
readonlyRootFilesystem
@Stability(Stable) public ContainerDefinitionProps.Builder readonlyRootFilesystem(Boolean readonlyRootFilesystem) Sets the value ofContainerDefinitionOptions.getReadonlyRootFilesystem()
- Parameters:
readonlyRootFilesystem
- When this parameter is true, the container is given read-only access to its root file system.- Returns:
this
-
restartAttemptPeriod
@Stability(Stable) public ContainerDefinitionProps.Builder restartAttemptPeriod(Duration restartAttemptPeriod) Sets the value ofContainerDefinitionOptions.getRestartAttemptPeriod()
- Parameters:
restartAttemptPeriod
- A period of time that the container must run for before a restart can be attempted. A container can be restarted only once everyrestartAttemptPeriod
seconds. If a container isn't able to run for this time period and exits early, it will not be restarted.This property can't be used if
enableRestartPolicy
is set to false.You can set a minimum
restartAttemptPeriod
of 60 seconds and a maximumrestartAttemptPeriod
of 1800 seconds.- Returns:
this
-
restartIgnoredExitCodes
@Stability(Stable) public ContainerDefinitionProps.Builder restartIgnoredExitCodes(List<? extends Number> restartIgnoredExitCodes) Sets the value ofContainerDefinitionOptions.getRestartIgnoredExitCodes()
- Parameters:
restartIgnoredExitCodes
- A list of exit codes that Amazon ECS will ignore and not attempt a restart on. This property can't be used ifenableRestartPolicy
is set to false.You can specify a maximum of 50 container exit codes.
- Returns:
this
-
secrets
@Stability(Stable) public ContainerDefinitionProps.Builder secrets(Map<String, ? extends Secret> secrets) Sets the value ofContainerDefinitionOptions.getSecrets()
- Parameters:
secrets
- The secret environment variables to pass to the container.- Returns:
this
-
startTimeout
Sets the value ofContainerDefinitionOptions.getStartTimeout()
- Parameters:
startTimeout
- Time duration (in seconds) to wait before giving up on resolving dependencies for a container.- Returns:
this
-
stopTimeout
Sets the value ofContainerDefinitionOptions.getStopTimeout()
- Parameters:
stopTimeout
- Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own.- Returns:
this
-
systemControls
@Stability(Stable) public ContainerDefinitionProps.Builder systemControls(List<? extends SystemControl> systemControls) Sets the value ofContainerDefinitionOptions.getSystemControls()
- Parameters:
systemControls
- A list of namespaced kernel parameters to set in the container.- Returns:
this
-
ulimits
Sets the value ofContainerDefinitionOptions.getUlimits()
- Parameters:
ulimits
- An array of ulimits to set in the container.- Returns:
this
-
user
Sets the value ofContainerDefinitionOptions.getUser()
- Parameters:
user
- The user to use inside the container. This parameter maps to User in the Create a container section of the Docker Remote API and the --user option to docker run.- Returns:
this
-
workingDirectory
@Stability(Stable) public ContainerDefinitionProps.Builder workingDirectory(String workingDirectory) Sets the value ofContainerDefinitionOptions.getWorkingDirectory()
- Parameters:
workingDirectory
- The working directory in which to run commands inside the container.- Returns:
this
-
build
Builds the configured instance.- Specified by:
build
in interfacesoftware.amazon.jsii.Builder<ContainerDefinitionProps>
- Returns:
- a new instance of
ContainerDefinitionProps
- Throws:
NullPointerException
- if any required attribute was not provided
-