@Generated(value="jsii-pacmak/1.73.0 (build 6faeda3)", date="2023-01-25T18:29:10.573Z") public class ContainerDefinition extends Construct
Example:
TaskDefinition taskDefinition; Cluster cluster; // Add a container to the task definition ContainerDefinition specificContainer = taskDefinition.addContainer("Container", ContainerDefinitionOptions.builder() .image(ContainerImage.fromRegistry("/aws/aws-example-app")) .memoryLimitMiB(2048) .build()); // Add a port mapping specificContainer.addPortMappings(PortMapping.builder() .containerPort(7600) .protocol(Protocol.TCP) .build()); Ec2Service.Builder.create(this, "Service") .cluster(cluster) .taskDefinition(taskDefinition) .cloudMapOptions(CloudMapOptions.builder() // Create SRV records - useful for bridge networking .dnsRecordType(DnsRecordType.SRV) // Targets port TCP port 7600 `specificContainer` .container(specificContainer) .containerPort(7600) .build()) .build();
Modifier and Type | Class and Description |
---|---|
static class |
ContainerDefinition.Builder
A fluent builder for
ContainerDefinition . |
IConstruct.Jsii$Default, IConstruct.Jsii$Proxy
Modifier | Constructor and Description |
---|---|
protected |
ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef) |
|
ContainerDefinition(software.constructs.Construct scope,
java.lang.String id,
ContainerDefinitionProps props)
Constructs a new instance of the ContainerDefinition class.
|
Modifier and Type | Method and Description |
---|---|
void |
addContainerDependencies(ContainerDependency... containerDependencies)
This method adds one or more container dependencies to the container.
|
void |
addEnvironment(java.lang.String name,
java.lang.String value)
This method adds an environment variable to the container.
|
void |
addInferenceAcceleratorResource(java.lang.String... inferenceAcceleratorResources)
This method adds one or more resources to the container.
|
void |
addLink(ContainerDefinition container)
This method adds a link which allows containers to communicate with each other without the need for port mappings.
|
void |
addLink(ContainerDefinition container,
java.lang.String alias)
This method adds a link which allows containers to communicate with each other without the need for port mappings.
|
void |
addMountPoints(MountPoint... mountPoints)
This method adds one or more mount points for data volumes to the container.
|
void |
addPortMappings(PortMapping... portMappings)
This method adds one or more port mappings to the container.
|
void |
addScratch(ScratchSpace scratch)
This method mounts temporary disk space to the container.
|
void |
addToExecutionPolicy(PolicyStatement statement)
This method adds the specified statement to the IAM task execution policy in the task definition.
|
void |
addUlimits(Ulimit... ulimits)
This method adds one or more ulimits to the container.
|
void |
addVolumesFrom(VolumeFrom... volumesFrom)
This method adds one or more volumes to the container.
|
PortMapping |
findPortMapping(java.lang.Number containerPort,
Protocol protocol)
Returns the host port for the requested container port if it exists.
|
java.util.List<ContainerDependency> |
getContainerDependencies()
An array dependencies defined for container startup and shutdown.
|
java.lang.String |
getContainerName()
The name of this container.
|
java.lang.Number |
getContainerPort()
The port the container will listen on.
|
java.util.List<EnvironmentFileConfig> |
getEnvironmentFiles()
The environment files for this container.
|
java.lang.Boolean |
getEssential()
Specifies whether the container will be marked essential.
|
java.lang.String |
getImageName()
The name of the image referenced by this container.
|
java.lang.Number |
getIngressPort()
The inbound rules associated with the security group the task or service will use.
|
LinuxParameters |
getLinuxParameters()
The Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.
|
LogDriverConfig |
getLogDriverConfig()
The log configuration specification for the container.
|
java.lang.Boolean |
getMemoryLimitSpecified()
Whether there was at least one memory limit specified in this definition.
|
java.util.List<MountPoint> |
getMountPoints()
The mount points for data volumes in your container.
|
java.util.List<PortMapping> |
getPortMappings()
The list of port mappings for the container.
|
java.lang.Boolean |
getReferencesSecretJsonField()
Whether this container definition references a specific JSON field of a secret stored in Secrets Manager.
|
TaskDefinition |
getTaskDefinition()
The name of the task definition that includes this container definition.
|
java.util.List<Ulimit> |
getUlimits()
An array of ulimits to set in the container.
|
java.util.List<VolumeFrom> |
getVolumesFrom()
The data volumes to mount from another container in the same task definition.
|
CfnTaskDefinition.ContainerDefinitionProperty |
renderContainerDefinition()
Render this container definition to a CloudFormation object.
|
CfnTaskDefinition.ContainerDefinitionProperty |
renderContainerDefinition(TaskDefinition _taskDefinition)
Render this container definition to a CloudFormation object.
|
getNode, isConstruct, onPrepare, onSynthesize, onValidate, prepare, synthesize, validate
protected ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef)
protected ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public ContainerDefinition(software.constructs.Construct scope, java.lang.String id, ContainerDefinitionProps props)
scope
- This parameter is required.id
- This parameter is required.props
- This parameter is required.public void addContainerDependencies(ContainerDependency... containerDependencies)
containerDependencies
- This parameter is required.public void addEnvironment(java.lang.String name, java.lang.String value)
name
- This parameter is required.value
- This parameter is required.public void addInferenceAcceleratorResource(java.lang.String... inferenceAcceleratorResources)
inferenceAcceleratorResources
- This parameter is required.public void addLink(ContainerDefinition container, java.lang.String alias)
This parameter is only supported if the task definition is using the bridge network mode. Warning: The --link flag is a legacy feature of Docker. It may eventually be removed.
container
- This parameter is required.alias
- public void addLink(ContainerDefinition container)
This parameter is only supported if the task definition is using the bridge network mode. Warning: The --link flag is a legacy feature of Docker. It may eventually be removed.
container
- This parameter is required.public void addMountPoints(MountPoint... mountPoints)
mountPoints
- This parameter is required.public void addPortMappings(PortMapping... portMappings)
portMappings
- This parameter is required.public void addScratch(ScratchSpace scratch)
This adds the correct container mountPoint and task definition volume.
scratch
- This parameter is required.public void addToExecutionPolicy(PolicyStatement statement)
statement
- This parameter is required.public void addUlimits(Ulimit... ulimits)
ulimits
- This parameter is required.public void addVolumesFrom(VolumeFrom... volumesFrom)
volumesFrom
- This parameter is required.public PortMapping findPortMapping(java.lang.Number containerPort, Protocol protocol)
containerPort
- This parameter is required.protocol
- This parameter is required.public CfnTaskDefinition.ContainerDefinitionProperty renderContainerDefinition(TaskDefinition _taskDefinition)
_taskDefinition
- [disable-awslint:ref-via-interface] (unused but kept to avoid breaking change).public CfnTaskDefinition.ContainerDefinitionProperty renderContainerDefinition()
public java.util.List<ContainerDependency> getContainerDependencies()
public java.lang.String getContainerName()
public java.lang.Number getContainerPort()
public java.lang.Boolean getEssential()
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.
If this parameter is omitted, a container is assumed to be essential.
public java.lang.String getImageName()
public java.lang.Number getIngressPort()
This property is only used for tasks that use the awsvpc network mode.
public java.lang.Boolean getMemoryLimitSpecified()
public java.util.List<MountPoint> getMountPoints()
public java.util.List<PortMapping> getPortMappings()
Port mappings allow containers to access ports on the host container instance to send or receive traffic.
public TaskDefinition getTaskDefinition()
public java.util.List<Ulimit> getUlimits()
public java.util.List<VolumeFrom> getVolumesFrom()
public java.util.List<EnvironmentFileConfig> getEnvironmentFiles()
public LinuxParameters getLinuxParameters()
public LogDriverConfig getLogDriverConfig()
public java.lang.Boolean getReferencesSecretJsonField()