@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:38.684Z") @Stability(value=Stable) public class ContainerDefinition extends software.constructs.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. |
| Modifier | Constructor and Description |
|---|---|
|
ContainerDefinition(software.constructs.Construct scope,
String id,
ContainerDefinitionProps props)
Constructs a new instance of the ContainerDefinition class.
|
protected |
ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
void |
addContainerDependencies(ContainerDependency... containerDependencies)
This method adds one or more container dependencies to the container.
|
void |
addEnvironment(String name,
String value)
This method adds an environment variable to the container.
|
void |
addInferenceAcceleratorResource(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,
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 |
addSecret(String name,
Secret secret)
This method adds a secret as environment variable 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(Number containerPort,
Protocol protocol)
Returns the host port for the requested container port if it exists.
|
List<ContainerDependency> |
getContainerDependencies()
An array dependencies defined for container startup and shutdown.
|
String |
getContainerName()
The name of this container.
|
Number |
getContainerPort()
The port the container will listen on.
|
List<EnvironmentFileConfig> |
getEnvironmentFiles()
The environment files for this container.
|
Boolean |
getEssential()
Specifies whether the container will be marked essential.
|
String |
getImageName()
The name of the image referenced by this container.
|
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.
|
Boolean |
getMemoryLimitSpecified()
Whether there was at least one memory limit specified in this definition.
|
List<MountPoint> |
getMountPoints()
The mount points for data volumes in your container.
|
List<PortMapping> |
getPortMappings()
The list of port mappings for the container.
|
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.
|
List<Ulimit> |
getUlimits()
An array of ulimits to set in the container.
|
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.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected ContainerDefinition(software.amazon.jsii.JsiiObjectRef objRef)
protected ContainerDefinition(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable)
public ContainerDefinition(@NotNull
software.constructs.Construct scope,
@NotNull
String id,
@NotNull
ContainerDefinitionProps props)
scope - This parameter is required.id - This parameter is required.props - This parameter is required.@Stability(value=Stable)
public void addContainerDependencies(@NotNull
ContainerDependency... containerDependencies)
containerDependencies - This parameter is required.@Stability(value=Stable)
public void addEnvironment(@NotNull
String name,
@NotNull
String value)
name - This parameter is required.value - This parameter is required.@Stability(value=Stable)
public void addInferenceAcceleratorResource(@NotNull
String... inferenceAcceleratorResources)
inferenceAcceleratorResources - This parameter is required.@Stability(value=Stable)
public void addLink(@NotNull
ContainerDefinition container,
@Nullable
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 - @Stability(value=Stable)
public void addLink(@NotNull
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.@Stability(value=Stable)
public void addMountPoints(@NotNull
MountPoint... mountPoints)
mountPoints - This parameter is required.@Stability(value=Stable)
public void addPortMappings(@NotNull
PortMapping... portMappings)
portMappings - This parameter is required.@Stability(value=Stable)
public void addScratch(@NotNull
ScratchSpace scratch)
This adds the correct container mountPoint and task definition volume.
scratch - This parameter is required.@Stability(value=Stable)
public void addSecret(@NotNull
String name,
@NotNull
Secret secret)
name - This parameter is required.secret - This parameter is required.@Stability(value=Stable)
public void addToExecutionPolicy(@NotNull
PolicyStatement statement)
statement - This parameter is required.@Stability(value=Stable)
public void addUlimits(@NotNull
Ulimit... ulimits)
ulimits - This parameter is required.@Stability(value=Stable)
public void addVolumesFrom(@NotNull
VolumeFrom... volumesFrom)
volumesFrom - This parameter is required.@Stability(value=Stable) @Nullable public PortMapping findPortMapping(@NotNull Number containerPort, @NotNull Protocol protocol)
containerPort - This parameter is required.protocol - This parameter is required.@Stability(value=Stable) @NotNull public CfnTaskDefinition.ContainerDefinitionProperty renderContainerDefinition(@Nullable TaskDefinition _taskDefinition)
_taskDefinition - [disable-awslint:ref-via-interface] (unused but kept to avoid breaking change).@Stability(value=Stable) @NotNull public CfnTaskDefinition.ContainerDefinitionProperty renderContainerDefinition()
@Stability(value=Stable) @NotNull public List<ContainerDependency> getContainerDependencies()
@Stability(value=Stable) @NotNull public String getContainerName()
@Stability(value=Stable) @NotNull public Number getContainerPort()
@Stability(value=Stable) @NotNull public 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.
@Stability(value=Stable) @NotNull public String getImageName()
@Stability(value=Stable) @NotNull public Number getIngressPort()
This property is only used for tasks that use the awsvpc network mode.
@Stability(value=Stable) @NotNull public Boolean getMemoryLimitSpecified()
@Stability(value=Stable) @NotNull public List<MountPoint> getMountPoints()
@Stability(value=Stable) @NotNull public List<PortMapping> getPortMappings()
Port mappings allow containers to access ports on the host container instance to send or receive traffic.
@Stability(value=Stable) @NotNull public TaskDefinition getTaskDefinition()
@Stability(value=Stable) @NotNull public List<Ulimit> getUlimits()
@Stability(value=Stable) @NotNull public List<VolumeFrom> getVolumesFrom()
@Stability(value=Stable) @Nullable public List<EnvironmentFileConfig> getEnvironmentFiles()
@Stability(value=Stable) @Nullable public LinuxParameters getLinuxParameters()
@Stability(value=Stable) @Nullable public LogDriverConfig getLogDriverConfig()
@Stability(value=Stable) @Nullable public Boolean getReferencesSecretJsonField()
Copyright © 2022. All rights reserved.