aws-cdk-lib.aws_ecs.FirelensLogRouter

class FirelensLogRouter (construct)

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

Implements IConstruct, IDependable

Firelens log router.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ecs as ecs } from 'aws-cdk-lib';

declare const appProtocol: ecs.AppProtocol;
declare const containerImage: ecs.ContainerImage;
declare const environmentFile: ecs.EnvironmentFile;
declare const linuxParameters: ecs.LinuxParameters;
declare const logDriver: ecs.LogDriver;
declare const secret: ecs.Secret;
declare const taskDefinition: ecs.TaskDefinition;
const firelensLogRouter = new ecs.FirelensLogRouter(this, 'MyFirelensLogRouter', {
  firelensConfig: {
    type: ecs.FirelensLogRouterType.FLUENTBIT,

    // the properties below are optional
    options: {
      configFileType: ecs.FirelensConfigFileType.S3,
      configFileValue: 'configFileValue',
      enableECSLogMetadata: false,
    },
  },
  image: containerImage,
  taskDefinition: taskDefinition,

  // the properties below are optional
  command: ['command'],
  containerName: 'containerName',
  cpu: 123,
  disableNetworking: false,
  dnsSearchDomains: ['dnsSearchDomains'],
  dnsServers: ['dnsServers'],
  dockerLabels: {
    dockerLabelsKey: 'dockerLabels',
  },
  dockerSecurityOptions: ['dockerSecurityOptions'],
  entryPoint: ['entryPoint'],
  environment: {
    environmentKey: 'environment',
  },
  environmentFiles: [environmentFile],
  essential: false,
  extraHosts: {
    extraHostsKey: 'extraHosts',
  },
  gpuCount: 123,
  healthCheck: {
    command: ['command'],

    // the properties below are optional
    interval: cdk.Duration.minutes(30),
    retries: 123,
    startPeriod: cdk.Duration.minutes(30),
    timeout: cdk.Duration.minutes(30),
  },
  hostname: 'hostname',
  inferenceAcceleratorResources: ['inferenceAcceleratorResources'],
  linuxParameters: linuxParameters,
  logging: logDriver,
  memoryLimitMiB: 123,
  memoryReservationMiB: 123,
  portMappings: [{
    containerPort: 123,

    // the properties below are optional
    appProtocol: appProtocol,
    hostPort: 123,
    name: 'name',
    protocol: ecs.Protocol.TCP,
  }],
  privileged: false,
  pseudoTerminal: false,
  readonlyRootFilesystem: false,
  secrets: {
    secretsKey: secret,
  },
  startTimeout: cdk.Duration.minutes(30),
  stopTimeout: cdk.Duration.minutes(30),
  systemControls: [{
    namespace: 'namespace',
    value: 'value',
  }],
  ulimits: [{
    hardLimit: 123,
    name: ecs.UlimitName.CORE,
    softLimit: 123,
  }],
  user: 'user',
  workingDirectory: 'workingDirectory',
});

Initializer

new FirelensLogRouter(scope: Construct, id: string, props: FirelensLogRouterProps)

Parameters

  • scope Construct
  • id string
  • props FirelensLogRouterProps

Constructs a new instance of the FirelensLogRouter class.

Construct Props

NameTypeDescription
firelensConfigFirelensConfigFirelens configuration.
imageContainerImageThe image used to start a container.
taskDefinitionTaskDefinitionThe name of the task definition that includes this container definition.
command?string[]The command that is passed to the container.
containerName?stringThe name of the container.
cpu?numberThe minimum number of CPU units to reserve for the container.
disableNetworking?booleanSpecifies whether networking is disabled within the container.
dnsSearchDomains?string[]A list of DNS search domains that are presented to the container.
dnsServers?string[]A list of DNS servers that are presented to the container.
dockerLabels?{ [string]: string }A key/value map of labels to add to the container.
dockerSecurityOptions?string[]A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems.
entryPoint?string[]The ENTRYPOINT value to pass to the container.
environment?{ [string]: string }The environment variables to pass to the container.
environmentFiles?EnvironmentFile[]The environment files to pass to the container.
essential?booleanSpecifies whether the container is marked essential.
extraHosts?{ [string]: string }A list of hostnames and IP address mappings to append to the /etc/hosts file on the container.
gpuCount?numberThe number of GPUs assigned to the container.
healthCheck?HealthCheckThe health check command and associated configuration parameters for the container.
hostname?stringThe hostname to use for your container.
inferenceAcceleratorResources?string[]The inference accelerators referenced by the container.
linuxParameters?LinuxParametersLinux-specific modifications that are applied to the container, such as Linux kernel capabilities.
logging?LogDriverThe log configuration specification for the container.
memoryLimitMiB?numberThe amount (in MiB) of memory to present to the container.
memoryReservationMiB?numberThe soft limit (in MiB) of memory to reserve for the container.
portMappings?PortMapping[]The port mappings to add to the container definition.
privileged?booleanSpecifies whether the container is marked as privileged.
pseudoTerminal?booleanWhen this parameter is true, a TTY is allocated.
readonlyRootFilesystem?booleanWhen this parameter is true, the container is given read-only access to its root file system.
secrets?{ [string]: Secret }The secret environment variables to pass to the container.
startTimeout?DurationTime duration (in seconds) to wait before giving up on resolving dependencies for a container.
stopTimeout?DurationTime duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own.
systemControls?SystemControl[]A list of namespaced kernel parameters to set in the container.
ulimits?Ulimit[]An array of ulimits to set in the container.
user?stringThe user to use inside the container.
workingDirectory?stringThe working directory in which to run commands inside the container.

firelensConfig

Type: FirelensConfig

Firelens configuration.


image

Type: ContainerImage

The image used to start a container.

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


taskDefinition

Type: TaskDefinition

The name of the task definition that includes this container definition.

[disable-awslint:ref-via-interface]


command?

Type: string[] (optional, default: CMD value built into container image.)

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.


containerName?

Type: string (optional, default: id of node associated with ContainerDefinition.)

The name of the container.


cpu?

Type: number (optional, default: No minimum CPU units reserved.)

The minimum number of CPU units to reserve for the container.


disableNetworking?

Type: boolean (optional, default: false)

Specifies whether networking is disabled within the container.

When this parameter is true, networking is disabled within the container.


dnsSearchDomains?

Type: string[] (optional, default: No search domains.)

A list of DNS search domains that are presented to the container.


dnsServers?

Type: string[] (optional, default: Default DNS servers.)

A list of DNS servers that are presented to the container.


dockerLabels?

Type: { [string]: string } (optional, default: No labels.)

A key/value map of labels to add to the container.


dockerSecurityOptions?

Type: string[] (optional, default: No security labels.)

A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems.


entryPoint?

Type: string[] (optional, default: Entry point configured in container.)

The ENTRYPOINT value to pass to the container.

See also: https://docs.docker.com/engine/reference/builder/#entrypoint


environment?

Type: { [string]: string } (optional, default: No environment variables.)

The environment variables to pass to the container.


environmentFiles?

Type: EnvironmentFile[] (optional, default: No environment files.)

The environment files to pass to the container.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/taskdef-envfiles.html


essential?

Type: boolean (optional, default: true)

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.


extraHosts?

Type: { [string]: string } (optional, default: No extra hosts.)

A list of hostnames and IP address mappings to append to the /etc/hosts file on the container.


gpuCount?

Type: number (optional, default: No GPUs assigned.)

The number of GPUs assigned to the container.


healthCheck?

Type: HealthCheck (optional, default: Health check configuration from container.)

The health check command and associated configuration parameters for the container.


hostname?

Type: string (optional, default: Automatic hostname.)

The hostname to use for your container.


inferenceAcceleratorResources?

Type: string[] (optional, default: No inference accelerators assigned.)

The inference accelerators referenced by the container.


linuxParameters?

Type: LinuxParameters (optional, default: No Linux parameters.)

Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.

For more information see KernelCapabilities.


logging?

Type: LogDriver (optional, default: Containers use the same logging driver that the Docker daemon uses.)

The log configuration specification for the container.


memoryLimitMiB?

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

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.


memoryReservationMiB?

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

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.


portMappings?

Type: PortMapping[] (optional, default: No ports are mapped.)

The port mappings to add to the container definition.


privileged?

Type: boolean (optional, default: false)

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).


pseudoTerminal?

Type: boolean (optional, default: false)

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 to docker run.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_pseudoterminal


readonlyRootFilesystem?

Type: boolean (optional, default: false)

When this parameter is true, the container is given read-only access to its root file system.


secrets?

Type: { [string]: Secret } (optional, default: No secret environment variables.)

The secret environment variables to pass to the container.


startTimeout?

Type: Duration (optional, default: none)

Time duration (in seconds) to wait before giving up on resolving dependencies for a container.


stopTimeout?

Type: Duration (optional, default: none)

Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own.


systemControls?

Type: SystemControl[] (optional, default: No system controls are set.)

A list of namespaced kernel parameters to set in the container.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_systemcontrols


ulimits?

Type: Ulimit[] (optional)

An array of ulimits to set in the container.


user?

Type: string (optional, default: root)

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.

See also: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#ContainerDefinition-user


workingDirectory?

Type: string (optional, default: /)

The working directory in which to run commands inside the container.

Properties

NameTypeDescription
containerDependenciesContainerDependency[]An array dependencies defined for container startup and shutdown.
containerNamestringThe name of this container.
containerPortnumberThe port the container will listen on.
essentialbooleanSpecifies whether the container will be marked essential.
firelensConfigFirelensConfigFirelens configuration.
imageNamestringThe name of the image referenced by this container.
ingressPortnumberThe inbound rules associated with the security group the task or service will use.
memoryLimitSpecifiedbooleanWhether there was at least one memory limit specified in this definition.
mountPointsMountPoint[]The mount points for data volumes in your container.
nodeNodeThe tree node.
portMappingsPortMapping[]The list of port mappings for the container.
taskDefinitionTaskDefinitionThe name of the task definition that includes this container definition.
ulimitsUlimit[]An array of ulimits to set in the container.
volumesFromVolumeFrom[]The data volumes to mount from another container in the same task definition.
cpu?numberThe number of cpu units reserved for the container.
environmentFiles?EnvironmentFileConfig[]The environment files for this container.
linuxParameters?LinuxParametersThe Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.
logDriverConfig?LogDriverConfigThe log configuration specification for the container.
pseudoTerminal?booleanSpecifies whether a TTY must be allocated for this container.
referencesSecretJsonField?booleanWhether this container definition references a specific JSON field of a secret stored in Secrets Manager.

containerDependencies

Type: ContainerDependency[]

An array dependencies defined for container startup and shutdown.


containerName

Type: string

The name of this container.


containerPort

Type: number

The port the container will listen on.


essential

Type: boolean

Specifies whether the container will be 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.

If this parameter is omitted, a container is assumed to be essential.


firelensConfig

Type: FirelensConfig

Firelens configuration.


imageName

Type: string

The name of the image referenced by this container.


ingressPort

Type: number

The inbound rules associated with the security group the task or service will use.

This property is only used for tasks that use the awsvpc network mode.


memoryLimitSpecified

Type: boolean

Whether there was at least one memory limit specified in this definition.


mountPoints

Type: MountPoint[]

The mount points for data volumes in your container.


node

Type: Node

The tree node.


portMappings

Type: PortMapping[]

The list of port mappings for the container.

Port mappings allow containers to access ports on the host container instance to send or receive traffic.


taskDefinition

Type: TaskDefinition

The name of the task definition that includes this container definition.


ulimits

Type: Ulimit[]

An array of ulimits to set in the container.


volumesFrom

Type: VolumeFrom[]

The data volumes to mount from another container in the same task definition.


cpu?

Type: number (optional)

The number of cpu units reserved for the container.


environmentFiles?

Type: EnvironmentFileConfig[] (optional)

The environment files for this container.


linuxParameters?

Type: LinuxParameters (optional)

The Linux-specific modifications that are applied to the container, such as Linux kernel capabilities.


logDriverConfig?

Type: LogDriverConfig (optional)

The log configuration specification for the container.


pseudoTerminal?

Type: boolean (optional)

Specifies whether a TTY must be allocated for this container.


referencesSecretJsonField?

Type: boolean (optional)

Whether this container definition references a specific JSON field of a secret stored in Secrets Manager.

Methods

NameDescription
addContainerDependencies(...containerDependencies)This method adds one or more container dependencies to the container.
addEnvironment(name, value)This method adds an environment variable to the container.
addInferenceAcceleratorResource(...inferenceAcceleratorResources)This method adds one or more resources to the container.
addLink(container, alias?)This method adds a link which allows containers to communicate with each other without the need for port mappings.
addMountPoints(...mountPoints)This method adds one or more mount points for data volumes to the container.
addPortMappings(...portMappings)This method adds one or more port mappings to the container.
addScratch(scratch)This method mounts temporary disk space to the container.
addSecret(name, secret)This method adds a secret as environment variable to the container.
addToExecutionPolicy(statement)This method adds the specified statement to the IAM task execution policy in the task definition.
addUlimits(...ulimits)This method adds one or more ulimits to the container.
addVolumesFrom(...volumesFrom)This method adds one or more volumes to the container.
findPortMapping(containerPort, protocol)Returns the host port for the requested container port if it exists.
findPortMappingByName(name)Returns the port mapping with the given name, if it exists.
renderContainerDefinition(_taskDefinition?)Render this container definition to a CloudFormation object.
toString()Returns a string representation of this construct.

addContainerDependencies(...containerDependencies)

public addContainerDependencies(...containerDependencies: ContainerDependency[]): void

Parameters

  • containerDependencies ContainerDependency

This method adds one or more container dependencies to the container.


addEnvironment(name, value)

public addEnvironment(name: string, value: string): void

Parameters

  • name string
  • value string

This method adds an environment variable to the container.


addInferenceAcceleratorResource(...inferenceAcceleratorResources)

public addInferenceAcceleratorResource(...inferenceAcceleratorResources: string[]): void

Parameters

  • inferenceAcceleratorResources string

This method adds one or more resources to the container.


addLink(container, alias?)

public addLink(container: ContainerDefinition, alias?: string): void

Parameters

  • container ContainerDefinition
  • alias string

This method adds a link which allows containers to communicate with each other without the need for port mappings.

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.


addMountPoints(...mountPoints)

public addMountPoints(...mountPoints: MountPoint[]): void

Parameters

  • mountPoints MountPoint

This method adds one or more mount points for data volumes to the container.


addPortMappings(...portMappings)

public addPortMappings(...portMappings: PortMapping[]): void

Parameters

  • portMappings PortMapping

This method adds one or more port mappings to the container.


addScratch(scratch)

public addScratch(scratch: ScratchSpace): void

Parameters

  • scratch ScratchSpace

This method mounts temporary disk space to the container.

This adds the correct container mountPoint and task definition volume.


addSecret(name, secret)

public addSecret(name: string, secret: Secret): void

Parameters

  • name string
  • secret Secret

This method adds a secret as environment variable to the container.


addToExecutionPolicy(statement)

public addToExecutionPolicy(statement: PolicyStatement): void

Parameters

  • statement PolicyStatement

This method adds the specified statement to the IAM task execution policy in the task definition.


addUlimits(...ulimits)

public addUlimits(...ulimits: Ulimit[]): void

Parameters

  • ulimits Ulimit

This method adds one or more ulimits to the container.


addVolumesFrom(...volumesFrom)

public addVolumesFrom(...volumesFrom: VolumeFrom[]): void

Parameters

  • volumesFrom VolumeFrom

This method adds one or more volumes to the container.


findPortMapping(containerPort, protocol)

public findPortMapping(containerPort: number, protocol: Protocol): PortMapping

Parameters

  • containerPort number
  • protocol Protocol

Returns

  • PortMapping

Returns the host port for the requested container port if it exists.


findPortMappingByName(name)

public findPortMappingByName(name: string): PortMapping

Parameters

  • name string

Returns

  • PortMapping

Returns the port mapping with the given name, if it exists.


renderContainerDefinition(_taskDefinition?)

public renderContainerDefinition(_taskDefinition?: TaskDefinition): ContainerDefinitionProperty

Parameters

  • _taskDefinition TaskDefinition

Returns

  • ContainerDefinitionProperty

Render this container definition to a CloudFormation object.


toString()

public toString(): string

Returns

  • string

Returns a string representation of this construct.