aws-cdk-lib.aws_ecs.LinuxParameters

class LinuxParameters (construct)

LanguageType name
.NETAmazon.CDK.AWS.ECS.LinuxParameters
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#LinuxParameters
Javasoftware.amazon.awscdk.services.ecs.LinuxParameters
Pythonaws_cdk.aws_ecs.LinuxParameters
TypeScript (source)aws-cdk-lib » aws_ecs » LinuxParameters

Implements IConstruct, IDependable

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,
  }),
});

Initializer

new LinuxParameters(scope: Construct, id: string, props?: LinuxParametersProps)

Parameters

  • scope Construct
  • id string
  • props LinuxParametersProps

Constructs a new instance of the LinuxParameters class.

Construct Props

NameTypeDescription
initProcessEnabled?booleanSpecifies whether to run an init process inside the container that forwards signals and reaps processes.
maxSwap?SizeThe total amount of swap memory a container can use.
sharedMemorySize?numberThe value for the size of the /dev/shm volume.
swappiness?numberThis allows you to tune a container's memory swappiness behavior.

initProcessEnabled?

Type: boolean (optional, default: false)

Specifies whether to run an init process inside the container that forwards signals and reaps processes.


maxSwap?

Type: Size (optional, default: No swap.)

The total amount of swap memory a container can use.

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.


sharedMemorySize?

Type: number (optional, default: No shared memory.)

The value for the size of the /dev/shm volume.


swappiness?

Type: number (optional, default: 60)

This allows you to tune a container's memory swappiness behavior.

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

NameTypeDescription
nodeNodeThe tree node.

node

Type: Node

The tree node.

Methods

NameDescription
addCapabilities(...cap)Adds one or more Linux capabilities to the Docker configuration of a container.
addDevices(...device)Adds one or more host devices to a container.
addTmpfs(...tmpfs)Specifies the container path, mount options, and size (in MiB) of the tmpfs mount for a container.
dropCapabilities(...cap)Removes one or more Linux capabilities to the Docker configuration of a container.
renderLinuxParameters()Renders the Linux parameters to a CloudFormation object.
toString()Returns a string representation of this construct.

addCapabilities(...cap)

public addCapabilities(...cap: Capability[]): void

Parameters

  • cap Capability

Adds one or more Linux capabilities to the Docker configuration of a container.

Tasks launched on Fargate only support adding the 'SYS_PTRACE' kernel capability.


addDevices(...device)

public addDevices(...device: Device[]): void

Parameters

  • device Device

Adds one or more host devices to a container.


addTmpfs(...tmpfs)

public addTmpfs(...tmpfs: Tmpfs[]): void

Parameters

  • tmpfs Tmpfs

Specifies the container path, mount options, and size (in MiB) of the tmpfs mount for a container.

Only works with EC2 launch type.


dropCapabilities(...cap)

public dropCapabilities(...cap: Capability[]): void

Parameters

  • cap Capability

Removes one or more Linux capabilities to the Docker configuration of a container.


renderLinuxParameters()

public renderLinuxParameters(): LinuxParametersProperty

Returns

  • LinuxParametersProperty

Renders the Linux parameters to a CloudFormation object.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.