AwsLogDriverMode

class aws_cdk.aws_ecs.AwsLogDriverMode(value)

Bases: Enum

awslogs provides two modes for delivering messages from the container to the log driver.

ExampleMetadata:

infused

Example:

# cluster: ecs.Cluster

# Create a Task Definition for the container to start
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
task_definition.add_container("TheContainer",
    image=ecs.ContainerImage.from_asset(path.resolve(__dirname, "..", "eventhandler-image")),
    memory_limit_mi_b=256,
    logging=ecs.AwsLogDriver(stream_prefix="EventDemo", mode=ecs.AwsLogDriverMode.NON_BLOCKING)
)

# An Rule that describes the event trigger (in this case a scheduled run)
rule = events.Rule(self, "Rule",
    schedule=events.Schedule.expression("rate(1 min)")
)

# Pass an environment variable to the container 'TheContainer' in the task
rule.add_target(targets.EcsTask(
    cluster=cluster,
    task_definition=task_definition,
    task_count=1,
    container_overrides=[targets.ContainerOverride(
        container_name="TheContainer",
        environment=[targets.TaskEnvironmentVariable(
            name="I_WAS_TRIGGERED",
            value="From CloudWatch Events"
        )]
    )]
))

Attributes

BLOCKING

(default) direct, blocking delivery from container to driver.

NON_BLOCKING

The non-blocking message delivery mode prevents applications from blocking due to logging back pressure.

Applications are likely to fail in unexpected ways when STDERR or STDOUT streams block.