LinuxParameters
Linux-specific options that are applied to the container.
Example
declare const taskDefinition: ecs.TaskDefinition;
taskDefinition.addContainer('container', {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
memoryLimitMiB: 1024,
linuxParameters: new ecs.LinuxParameters(this, 'LinuxParameters', {
initProcessEnabled: true,
sharedMemorySize: 1024,
maxSwap: Size.mebibytes(5000),
swappiness: 90,
}),
});
# task_definition: ecs.TaskDefinition
task_definition.add_container("container",
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
memory_limit_mi_b=1024,
linux_parameters=ecs.LinuxParameters(self, "LinuxParameters",
init_process_enabled=True,
shared_memory_size=1024,
max_swap=Size.mebibytes(5000),
swappiness=90
)
)
TaskDefinition taskDefinition;
taskDefinition.addContainer("container", ContainerDefinitionOptions.builder()
.image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
.memoryLimitMiB(1024)
.linuxParameters(LinuxParameters.Builder.create(this, "LinuxParameters")
.initProcessEnabled(true)
.sharedMemorySize(1024)
.maxSwap(Size.mebibytes(5000))
.swappiness(90)
.build())
.build());
// Install: dotnet add package Amazon.CDK.Lib
TaskDefinition taskDefinition;
taskDefinition.AddContainer("container", new ContainerDefinitionOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryLimitMiB = 1024,
LinuxParameters = new LinuxParameters(this, "LinuxParameters", new LinuxParametersProps {
InitProcessEnabled = true,
SharedMemorySize = 1024,
MaxSwap = Size.Mebibytes(5000),
Swappiness = 90
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var taskDefinition TaskDefinition
taskDefinition.AddContainer(jsii.String("container"), &ContainerDefinitionOptions{
Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
MemoryLimitMiB: jsii.Number(1024),
LinuxParameters: ecs.NewLinuxParameters(this, jsii.String("LinuxParameters"), &LinuxParametersProps{
InitProcessEnabled: jsii.Boolean(true),
SharedMemorySize: jsii.Number(1024),
MaxSwap: awscdk.Size_Mebibytes(jsii.Number(5000)),
Swappiness: jsii.Number(90),
}),
})
Initializer
new LinuxParameters(scope: Construct, id: string, props?: LinuxParametersProps)
LinuxParameters(scope: Construct, id: str, props: typing.Optional[LinuxParametersProps] = None)
new LinuxParameters(Construct scope, String id, LinuxParametersProps props)
new LinuxParameters(Construct scope, string id, LinuxParametersProps? props = null)
NewLinuxParameters(Scope Construct, Id *string, Props LinuxParametersProps)
Construct Props
initProcessEnabledbooleaninit_process_enabledboolinitProcessEnabledBooleanInitProcessEnabledboolInitProcessEnabled*bool= false#This parameter will be translated to the --memory-swap option to docker run.
This parameter is only supported when you are using the EC2 launch type. Accepted values are positive integers.
notes
This parameter maps to the --memory-swappiness option to docker run. The swappiness relates to the kernel's tendency to swap memory. A value of 0 will cause swapping to not happen unless absolutely necessary. A value of 100 will cause pages to be swapped very aggressively.
This parameter is only supported when you are using the EC2 launch type. Accepted values are whole numbers between 0 and 100. If a value is not specified for maxSwap then this parameter is ignored.
Properties
Methods
addCapabilities(...cap: Capability[]): voiddef add_capabilities(self, cap: Capability) -> Nonepublic void addCapabilities(Capability cap)public void AddCapabilities(Capability cap)func AddCapabilities(Cap Capability)#Tasks launched on Fargate only support adding the 'SYS_PTRACE' kernel capability.
addDevices(...device: Device[]): voiddef add_devices(self, device: Device) -> Nonepublic void addDevices(Device device)public void AddDevices(Device device)func AddDevices(Device Device)#addTmpfs(...tmpfs: Tmpfs[]): voiddef add_tmpfs(self, tmpfs: Tmpfs) -> Nonepublic void addTmpfs(Tmpfs tmpfs)public void AddTmpfs(Tmpfs tmpfs)func AddTmpfs(Tmpfs Tmpfs)#Only works with EC2 launch type.
dropCapabilities(...cap: Capability[]): voiddef drop_capabilities(self, cap: Capability) -> Nonepublic void dropCapabilities(Capability cap)public void DropCapabilities(Capability cap)func DropCapabilities(Cap Capability)#isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
renderLinuxParameters(): CfnTaskDefinition.LinuxParametersPropertydef render_linux_parameters(self, ) -> LinuxParametersPropertypublic LinuxParametersProperty renderLinuxParameters()public LinuxParametersProperty RenderLinuxParameters()func RenderLinuxParameters() LinuxParametersProperty#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.
1 parameter · returns
Parameters
mixinsmixinsmixinsmixinsMixins— The mixins to apply.
Returns: This construct for chaining