class AwsLogDriver
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.AwsLogDriver |
Java | software.amazon.awscdk.services.ecs.AwsLogDriver |
Python | aws_cdk.aws_ecs.AwsLogDriver |
TypeScript (source) | @aws-cdk/aws-ecs » AwsLogDriver |
Extends
Log
A log driver that sends log information to CloudWatch Logs.
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'
}],
}],
}));
Initializer
new AwsLogDriver(props: AwsLogDriverProps)
Parameters
- props
Aws
— the awslogs log driver configuration options.Log Driver Props
Constructs a new instance of the AwsLogDriver class.
Properties
Name | Type | Description |
---|---|---|
log | ILog | The log group to send log streams to. |
logGroup?
Type:
ILog
(optional)
The log group to send log streams to.
Only available after the LogDriver has been bound to a ContainerDefinition.
Methods
Name | Description |
---|---|
bind(scope, containerDefinition) | Called when the log driver is configured on a container. |
bind(scope, containerDefinition)
public bind(scope: Construct, containerDefinition: ContainerDefinition): LogDriverConfig
Parameters
- scope
Construct
- containerDefinition
Container
Definition
Returns
Called when the log driver is configured on a container.