enum AwsLogDriverMode
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.AwsLogDriverMode |
Java | software.amazon.awscdk.services.ecs.AwsLogDriverMode |
Python | aws_cdk.aws_ecs.AwsLogDriverMode |
TypeScript (source) | @aws-cdk/aws-ecs » AwsLogDriverMode |
awslogs provides two modes for delivering messages from the container to the log driver.
Example
declare const cluster: ecs.Cluster;
// Create a Task Definition for the container to start
const taskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef');
taskDefinition.addContainer('TheContainer', {
image: ecs.ContainerImage.fromAsset(path.resolve(__dirname, '..', 'eventhandler-image')),
memoryLimitMiB: 256,
logging: new ecs.AwsLogDriver({ streamPrefix: 'EventDemo', mode: ecs.AwsLogDriverMode.NON_BLOCKING }),
});
// An Rule that describes the event trigger (in this case a scheduled run)
const rule = new events.Rule(this, 'Rule', {
schedule: events.Schedule.expression('rate(1 min)'),
});
// Pass an environment variable to the container 'TheContainer' in the task
rule.addTarget(new targets.EcsTask({
cluster,
taskDefinition,
taskCount: 1,
containerOverrides: [{
containerName: 'TheContainer',
environment: [{
name: 'I_WAS_TRIGGERED',
value: 'From CloudWatch Events'
}],
}],
}));
Members
Name | Description |
---|---|
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. |
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.